Netbeans-Platform RefCard

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

#80

Get More Refcardz! Visit refcardz.com


CONTENTS INCLUDE:
n n

About NetBeans Platform Getting Started Main Benefits NetBeans Platform Modules NetBeans Platform APIs NetBeans Platform Gotchas and more...

Essential NetBeans Platform


By Heiko Bck, Anton Epple, Milo ilhnek, Andreas Stefik, Geertjan Wielenga, and Tom Wheeler
Window System Most serious applications need more than one window. Coding good interaction between multiple windows is not a trivial task. The NetBeans window system lets you maximize/minimize, dock/undock, and drag-anddrop windows, without you providing the code. Swing is the standard UI toolkit and is the basis of all NetBeans Platform applications. A related benefit is that you can change look & feels very easily, and add internationalization and Java 2D effects to your applications With the NetBeans Platform, youre not constrained by one of the typical pain points in Swing: the JTree model is completely different than the JList model, even though they present the same data. Switching between them means rewriting the model. The NetBeans Nodes API provides a generic model for presenting your data. The NetBeans Explorer & Property Sheet API provides several advanced Swing components for displaying Nodes. In addition to a window system, the NetBeans Platform provides many other UI-related components, such as a property sheet, a palette, wizards, complex Swing components for presenting data, a Plugin Manager, and an Output window. The JavaHelp API is an integral part of the NetBeans Platform. You can create help sets in each of your modules and the NetBeans Platform will automatically resolve them into a single helpset. You can also bind help topics to UI components to create a context-sensitive help system for your application.

ABOUT NETBEANS PLATFORM


The NetBeans Platform is a generic framework for commercial and open source desktop Swing applications. It provides the plumbing that you would otherwise need to write yourself, such as the code for managing windows, connecting actions to menu items, and updating applications at runtime. The NetBeans Platform provides all of these out of the box on top of a reliable, flexible, and well-tested modular architecture. In this refcard, you are introduced to the key concerns of the NetBeans Platform, so that you can save years of work when developing robust and extensible applications.

Standardized UI Toolkit Generic Presentation Layer

Advanced Swing Components

JavaHelp Integration

GETTING STARTED
To get started with the NetBeans Platform:
Approach
IDE

How to Get Started


Download NetBeans IDE, which includes NetBeans Platform development tools such as templates, wizards, and complete NetBeans Platform samples out of the box. Use the Maven archetypes for NetBeans Platform development: NetBeans Platform archetype: - GroupId: org.codehaus.mojo.archetypes - ArtifactId: netbeans-platform-app-archetype NetBeans Module archetype: - GroupId: org.codehaus.mojo.archetypes - ArtifactId: nbm-archetype

NETBEANS PLATFORM MODULES


The NetBeans Platform consists of a large set of modules. You do not need all of them. In fact, you only need 5. You also do not need to have a user interface, meaning that you can create server/console applications on the NetBeans Platform. The complete list of NetBeans Platform modules is provided below. Items in red are mandatory, items in green are optional.
Module
boot.jar core.jar org-openide-filesystems.jar org-openide-modules.jar org-openide-util.jar org-netbeans-core.jar org-netbeans-core-execution.jar org-netbeans-core-ui.jar org-netbeans-core-windows.jar

www.dzone.com

Maven

Ant

Download the NetBeans Platform ZIP file, which includes a build harness. The build harness includes a long list of Ant targets for compiling, running, testing, and packaging NetBeans Platform applications.

Description
Provides the runtime container.

Join the NetBeans Community mailing lists!

MAIN BENEFITS
The following are the main features of the NetBeans Platform, showing you the benefits of using it rather than your homegrown Swing framework.
Feature Description
Modularity offers a solution to JAR hell by letting you organize code into strictly separated and versioned modules. Only modules that have explicitly declared dependencies on each other are able to use code from each others exposed packages. This strict organization is of particular relevance to large applications developed by engineers in distributed environments, during the development as well as the maintenance of their shared codebase. Just as application servers such as GlassFish provide lifecycle services to web applications, the NetBeans runtime container provides services to Swing applications. Application servers understand how to compose web modules, EJB modules, and so on, into a single web application, just as the NetBeans runtime container understands how to compose NetBeans modules into a single Swing application. End users of the application benefit because they are able to install modules into their running applications via an update center, since NetBeans modules can be installed, uninstalled, activated, and deactivated at runtime. The NetBeans Platform provides an infrastructure for registering and retrieving service implementations, enabling you to minimize direct dependencies between individual modules and enabling a loosely coupled architecture with high cohesion and low coupling. Unified API providing stream-oriented access to flat and hierarchical structures, such as disk-based files on local or remote servers, memory-based files and even XML documents. Module System

Provides the basic UI components provided by the NetBeans Platform, together with related infrastructure.

Essential NetBeans Platform

Lifecycle Management

Pluggability

Service Infrastructure

File System

DZone, Inc.

www.dzone.com

Essential NetBeans Platform

org-netbeans-core-output2.jar org-openide-io.jar

Provides an Output window for displaying processing messages. It also exposes an API that you can use to write to the window and change text colors. Provides a framework for multi-tab windows, such as used by the Matisse GUI Builder in NetBeans IDE. Provides the API for accessing the window system. Provides the Plugin Manager together with the functionality for accessing and processing update centers where NetBeans modules are stored. Provides a customizable window which can be used as a filechooser, enabling the user to select and open folders and files. Provides a number of configurable system actions, such as Cut, Copy, and Paste. Provides an API that lets an application recognize file types. Provides the API for modeling business objects and displaying them to the user. Provides the JavaHelp runtime library and enables JavaHelp sets from different modules to be merged into a single helpset. Provides an API for discovery and creation of settings specific to file types. Provides a central wrapper file system for your application. Provides an Options window for user customizations and an API for extending it. Provides support for asynchronous long running tasks and integration for long running tasks with the NetBeans Platforms progress bar. Provides an API for getting information about files and an SPI for creating your own queries. Provides an API and SPI for registering your own handlers for accessing the command line. Provides an API for saving module-specific settings in a user-defined format. Provides many helper classes for displaying UI elements such as notifications. Provides an API for displaying standard and customized dialogs. Provides an extension to the javax.swing,text API. Provides a widget & graph library for modeling and displaying visual representations of data. Provides the infrastructure for integrating items into the Quick Search field. Provides the look and feel and the display of tabs and a wrapper for the Swing Layout Extensions library.

Module System
A module is a JAR file with special attributes in its manifest file. This is a typical NetBeans Platform manifest file:
Manifest-Version: 1.0 Ant-Version: Apache Ant 1.7.1 Created-By: 11.3-b02 (Sun Microsystems Inc.) OpenIDE-Module-Public-Packages: OpenIDE-Module-Module-Dependencies: org.openide.util > 7.31.1.1 OpenIDE-Module-Java-Dependencies: Java > 1.5 OpenIDE-Module-Implementation-Version: 091216 AutoUpdate-Show-In-Client: true OpenIDE-Module: org.demo.hello OpenIDE-Module-Layer: org/demo/hello/layer.xml OpenIDE-Module-Localizing-Bundle: org/demo/hello/Bundle.properties OpenIDE-Module-Specification-Version: 1.0 OpenIDE-Module-Requires: org.openide.modules.ModuleFormat1

org-netbeans-core-multiview.jar

org-openide-windows.jar org-netbeans-modules-autoupdate-services.jar org-netbeans-modules-autoupdate-ui.jar

org-netbeans-modules-favorites.jar

org-openide-actions.jar org-openide-loaders.jar org-openide-nodes.jar org-openide-explorer.jar org-netbeans-swing-outline.jar org-netbeans-modules-javahelp.jar

These are the most important NetBeans-related manifest attributes.


Type
OpenIDE-Module

Description
The identifier of a module, providing a unique name used for recognition by the module system. This is the only required entry in a manifest file for a module. The location and name of the modules layer. xml file, if any. By default, all packages in a module are hidden from all other modules. Via this attribute, you expose packages to external modules. The location and name of a properties file providing a display name and the like. Modules can request general or specific versions of other modules (|OpenIDE-Module-ModuleDependencies|), Java packages (|OpenIDEModule-Package-Dependencies|), or Java itself (|OpenIDE-Module-Java-Dependencies|). Modules can specify dependencies without naming the exact module to depend on. A module may /provide/ one or more /tokens/. These are strings of conventional meaning, in the format of a Java package or class name. In line with the Java Versioning Specification, modules can indicate two pieces of version information about themselves using the |OpenIDE-Module-Specification-Version| and the |OpenIDE-Module-Implementation-Version| tags.

org-netbeans-modules-mimelookup.jar org-netbeans-modules-editor-mimelookup.jar org-netbeans-modules-masterfs.jar org-netbeans-modules-options-api.jar org-netbeans-api-progress.jar org-openide-execution.jar org-netbeans-modules-progress-ui.jar org-netbeans-modules-queries.jar

OpenIDE-Module-Layer OpenIDE-Module-Public-Packages

OpenIDE-Module-Localizing-Bundle OpenIDE-Module-Module-Dependencies OpenIDE-Module-Java-Dependencies

org-netbeans-modules-sendopts.jar

OpenIDE-Module-Provides OpenIDE-Module-Requires

org-netbeans-modules-settings.jar org-openide-awt.jar org-openide-dialogs.jar org-openide-text.jar org-netbeans-api-visual.jar org-netbeans-spi-quicksearch.jar org-netbeans-swing-plaf.jar org-netbeans-swing-tabcontrol org-jdesktop-layout.jar

OpenIDE-Module-Specification-Version OpenIDE-Module-Implementation-Version

AutoUpdate-Show-In-Client

This attribute determines whether the module is shown in the Plugin Manager.

For details on these and other attributes, see http://bits.netbeans.org/6.8/javadoc/org-openide-modules.

Hot Tip

To influence the lifecycle of a module, extend org.openide.modules.ModuleInstall, and register it in the manifest under the OpenIDE-Module-Install key.

Some of the items in the list above can be used outside of the NetBeans Platform. In these cases, you can put the JAR on the classpath of a standard Swing application and use the related functionality there: org-openide-filesystems.jar (to use the virtual filesystem), org-openide-util.jar (to use the Lookup class), org-openide-nodes.jar & org-openide-explorer.jar (to use Nodes and explorer views), org-netbeans-swing-outline. jar (to use a Swing treetable component), org-netbeans-apivisual.jar (to use the widget library).

Window System
The window system handles the display of JPanel-like components and integrates them with the NetBeans Platform. The main classes are listed below.
Type
TopComponent

Description
A JPanel that provides a new window in your application. The window comes with many features for free, such as maximize/minimize and dock/undock. A container in which TopComponents are docked. You do not need to subclass this class to use it. Instead, it is configured in an XML file. A group of windows, which should behave in concert. For example, windows within a group can be opened or closed together. As with Modes, these are defined in an XML file, not by subclassing TopComponentGroup. Controls all the windows, modes, and window groups. You can request the WindowManager for its windows, modes, and groups. You can also cast it to a JFrame and then set the title bar and anything else that you would do with JFrames.

Mode TopComponentGroup

NETBEANS PLATFORM APIs


The NetBeans Platform provides a large set of APIs. You do not need to know or use all of them, just those that make sense in your specific context. Below are the main API groupings, together with the most important information related to the grouping, such as their most important configuration attributes and API classes.
DZone, Inc.
|

WindowManager

A mode, that is, a window position, is defined in an XML file, which is contributed to the System FileSystem via registration
www.dzone.com

Essential NetBeans Platform

entries in the layer.xml file. The NetBeans Platform provides a set of default modes, the most important of which are as follows:
Type
editor explorer properties navigator output palette leftSlidingSide rightSlidingSide bottomSlidingSide

of your application, but also into the context of NetBeans UI components, such as windows and Nodes. These are the most important Lookups to be aware of:
Type
Global lookup, provides selection management

Description
main area of application (not necessarily an actual editor) left vertical area, such as for a Projects window right vertical area, typically for a Properties window left lower vertical area horizontal area at base of application right vertical area for items to drag into a visual pane minimized state in left sidebar minimized state in right sidebar minimized state in bottom status area

Description
The Lookup that gives you access to the currently selected UI component, most commonly the focused Node. Lookup lkp = Utilities.actionsGlobalContext();

Local lookup, provides lookup of NetBeans objects such as windows and Nodes

The local context of a specific NetBeans Platform UI object. //For Windows components: Lookup lkp = myTopComponent,getLookup(); //For Nodes: Lookup lkp = myNode.getLookup();

Default lookup

The applications context, comparable to the JDK 6 ServiceLoader class, provided via the META-INF/services folder. Lookup lkp = Lookup.getDefault();

A TopComponent is registered in a mode as follows, note especially the lines in bold below:
<folder name=Windows2> <folder name=Components> <file name=MyTopComponent.settings url=MyTopComponentSettings.xml/> </folder> <foldername=Modes> <foldername=editor> <file name=MyTopComponent.wstcref url=MyTopComponentWstcref.xml/> </folder> </folder> </folder>

These are typical tasks related to Lookup and how to code them:
How do I...
Register a service?

Description
Annotate a service provider with the @ServiceProvider class annotation, at compile time the METAINF/services folder is created, registering the implementation. MyService svc = Lookup.getDefault().lookup(MyService.class) Collection<? extends MyService> coll = Lookup.getDefault(). lookupAll(MyService.class) Lookup.Result lkpResult = theLookup.lookupResult(MyObject. class); lkpResult.addLookupListener( new LookupListener() { @Override public void resultChanged(LookupEvent e)( Result res = (Result) e.getSource(); Collection<? extends MyObject> coll = res.allInstance(); //iterate through the collection } ); lkpResult.allInstances(); // first call is needed

Find the default service implementation? Find all service implementations? Listen to changes in a Lookup? Tip: Keep a reference to the result object, otherwise it will be garbage collected.

The XML files referred to above are small settings files that NetBeans IDE can generate for you. Though the default modes should be sufficient for most business scenarios, you might like to adjust them. In that case, you are creating your own mode definitions. A mode definition must follow the related DTD, which is as follows: http://netbeans.org/dtds/mode-properties2_1.dtd

Create a Lookup for an object?

//Lookup for single object: Lookup lkp = Lookups.singleton( myObject ); //Lookup for multiple objects: Lookup lkp = Lookups.fixed(myObject, other); //Lookup for dynamic content: InstanceContent ic = new InstanceContent(); Lookup lkp = new AbstractLookup(ic); ic.add(myObject);

Hot Tip

Hide the existing modes and create your own, if the existing ones are really not sufficient for you.
Merge Lookups? Provide a Lookup for my TopComponent? Provide a Lookup for a subclass of AbstractNode?

The window manager handles the display of the windows in the applications main frame. Aside from being able to access its main Frame, you can also query it for information, as listed below:
How do I...
Find a specific TopComponent? Find a specific mode?

Lookup commonlkp = new ProxyLookup( dataObjectLookup, nodeLookup, dynamicLookup); //In the constructor of TopComponent: associateLookup(myLookup); new AbstractNode(myKids, myLookup);

Description
WindowManager.getDefault().findTopComponent(id) WindowManager.getDefault().findMode(id) Once you have found a mode, you can use Mode.dockInto(tc) to programmatically dock a TopComponent into a specific mode.

Central Registry (System FileSystem)


The central registry is organized as a virtual file system accessible by all the modules in a NetBeans Platform application. NetBeans Platform APIs, such as the Window System API, make available extension points enabling you to declaratively register your components. A modules contributions to the system are provided by specialized XML files, called layer files, normally named layer.xml. Below are the most important extension points provided out of the box by the NetBeans APIs, represented by folders in a layer file:
Actions, Menu, Toolbars, Navigator/Panels, OptionsDialog, Services, Shortcuts, TaskList, and Windows2.

Find a specific TopComponentGroup? Ensure that the application is fully started up? Get the active TopComponent? Get a set of opened TopComponents? Get the main frame of the application

WindowManager.getDefault().findTopComponent Group(id) WindowManager.getDefault().invokeWhenUIReady(Runnable) WindowManager.getDefault().getRegistry(). getActivated() WindowManager.getDefault().getRegistry().getOpened() WindowManager.getDefault().getMainWindow()

Lookup
Lookup is a data structure for loosely coupled communication. It is similar to but more powerful than the ServiceLoader class in JDK 6 (for example, Lookup supports event notifications) enabling you to load objects into the context
DZone, Inc.
|

The NetBeans Platform helps you to register items correctly in the file system by letting you, in some cases, annotate your classes instead of requiring you to manually type XML tags in the layer.xml file by hand. The current set of annotations impacting the layer.xml is listed below:
www.dzone.com

Essential NetBeans Platform

@AntBasedProjectRegistration, @CompositeCategoryProvider.Registration, @EditorActionRegistration,@LookupMerger.Registration, @LookupProvider. Registration, @NodeFactory.Registration, @OptionsPanelController. ContainerRegistration, @OptionsPanelController.SubRegistration, @OptionsPanelController.TopLevelRegistration, @ProjectServiceProvider, @ServiceProvider, @ServicesTabNodeRegistration

actions (AbstractAction, ActionListener, etc) in any way. Instead, you need to bind them to one of the classes listed above, using the layer.xml file to do so. Actions.alwaysEnabled:
<file name=your-pkg-action-id.instance> <attr name=instanceCreate methodvalue=org.openide.awt.Actions.alwaysEnabled/> <attr name=delegate methodvalue=your.pkg.YourAction.factoryMethod/> <attr name=displayName bundlevalue=your.pkg.Bundle#key/> <attr name=iconBase stringvalue=your/pkg/YourImage.png/> <!-- if desired: <attr name=noIconInMenu boolvalue=false/> <!-- if desired: <attr name=asynchronous boolvalue=true/> </file>

The registry makes use of the FileSystem API to access the registered data.

FileSystem API
The FileSystem API provides stream-oriented access to flat and hierarchical structures, such as disk-based files on local or remote servers, memory-based files and even XML documents. Items within the folders in the layer.xml file are not java.io.Files, but org.openide.filesystems.FileObjects. The differences between them are as follows:
java.io.File
Create with a constructor Can represent something that doesnt exist, such as new File(some/place/that/doesnt/ exist) Cannot listen to changes Represents a file on disk No attributes

Actions.context:
<file name=action-pkg-ClassName.instance> <attr name=instanceCreate methodvalue=org.openide.awt.Actions.context/> <attr name=type stringvalue=org.netbeans.api.actions.Openable/> <attr name=selectionType stringvalue=ANY/> (or EXACTLY_ONE) <attr name=delegate newvalue=action.pkg.YourAction/> <attr name=key stringvalue=KeyInActionMap/> <attr name=surviveFocusChange boolvalue=false/> <attr name=displayName bundlevalue=your.pkg.Bundle#key/> <attr name=iconBase stringvalue=your/pkg/YourImage.png/> <!-- if desired: <attr name=noIconInMenu boolvalue=false/> <!-- if desired: <attr name=asynchronous boolvalue=true/> </file>

org.openide.filesystems.FileObject
Get from the FileSystem Typically represents something that exists

FileChangeListener listens to changes to FileObject, as well as anything beneath the FileObject Not necessarily a file on disk, could be in a database, FTP server, virtual, or anywhere else Can have attributes, which are key-value pairs associated with a FileObject

Actions.callback:
<file name=action-pkg-ClassName.instance> <attr name=instanceCreate methodvalue=org.openide.awt.Actions.callback/> <attr name=key stringvalue=KeyInActionMap/> <attr name=surviveFocusChange boolvalue=false/> <attr name=fallback newvalue=action.pkg.DefaultAction/> <attr name=displayName bundlevalue=your.pkg.Bundle#key/> <attr name=iconBase stringvalue=your/pkg/YourImage.png/> <!-- if desired: <attr name=noIconInMenu boolvalue=false/> <!-- if desired: <attr name=asynchronous boolvalue=true/> </file>

Converting between common data types:


How do I get...
a java.io.File for a FileObject? a FileObject for a File? a DataObject for a FileObject? a FileObject for a DataObject? a Node for a DataObject? a DataObject for a Node?

Description
FileUtil.toFile(FileObject fo) FileUtil.toFileObject(File f) DataObject.find (theFileObject) theDataObject.getPrimaryFile() theDataObject.getNodeDelegate() DataObject dob = (DataObject) theNode. getLookup().lookup (DataObject.class); if (dob != null) { //do something } //Get the root: FileUtil.getConfigRoot() //Get a specific folder: FileUtil.getConfigFile(path/to/my/folder)

For all the details, see http://bits.netbeans.org/6.8/javadoc/ org-openide-awt/org/openide/awt/Actions.html An action is registered in the layer.xml file in the Actions folder, within a folder reflecting its place in the action pool.
<folder name=Actions> <folder name=Window> <file name=your-pkg-action-id.instance> ... </file> </folder> </folder>

a reference to the System FileSystem?

The NetBeans Platform provides a number of custom URLs for accessing things.
jar nbres nbresloc For representing entries inside JARs and ZIPs, including the root directory entry A resource loaded from a NetBeans module, e.g. nbres:/org/netbeans/modules/foo/resources/foo.dtd Same, but transparently localized and branded according to the usual conventions, e.g. nbresloc:/org/netbeans/modules/foo/resources/foo.html may actually load the same thing as nbres:/org/netbeans/modules/foo/resources/foonbja.html. Loads installation files using InstalledFileLocator in installation directories, e.g. nbinst:///modules/ext/some-lib.jar may load the same thing as file:/opt/netbeans/ ide4/modules/ext/some-lib.jar. Refers to a file object in the System FileSystem (XML layers). For example, nbfs:/ SystemFileSystem/Templates/Other/html.html refers to an HTML file template installed in the IDE

Depending on your business requirements, once you have actions registered in the layer.xml file, you need to bind them to menu items, toolbar buttons, and keyboard shortcuts. Menu Items
<folder name=Menu> <folder name=Window> <file name=your-pkg-action-id.shadow> <attr name=originalFile stringvalue=Actions/Window/ your-pkg-action-id.instance/> <attr name=position intvalue=50/> </file> </folder> </folder>

nbinst

nbfs

Actions
Actions are pieces of code that are invoked when the user presses a menu item, toolbar button, or keyboard shortcut.
Type
Actions.alwaysEnabled Actions.context Actions.callback

Toolbar Buttons
<folder name=Toolbars> <folder name=Window> <file name=your-pkg-action-id.shadow> <attr name=originalFile stringvalue=Actions/Window/ your-pkg-action-id.instance/> <attr name=position intvalue=50/> </file> </folder> </folder>

Description
An action that is always enabled. Typically, use this for File > Open actions, for example. An action that is bound to a context. If an action should only be enabled under certain conditions, use this action. An action with an assigned key used to find a delegate in the ActionMap of the active component.

When porting your existing application to the NetBeans Platform, you do not need to change your standard JDK
DZone, Inc.
|

www.dzone.com

Essential NetBeans Platform

Shortcuts
<folder name=Shortcuts> <file name=M.shadow> <attr name=originalFile stringvalue=Actions/Edit/org-netbeans-modulessome-MyAction.instance/> </file> <file name=D-M.shadow> <attr name=originalFile stringvalue=Actions/Edit/org-netbeans-modules some-CtrlMyAction.instance/> </file> <file name=O-M.shadow> <attr name=originalFile stringvalue=Actions/Edit/org-netbeans-modules some-AltMyAction.instance/> </file> </folder>

LayerWidget ComponentWidget ImageWidget LabelWidget IconNodeWidget ConnectionWidget ConvolveWidget LevelOfDetailsWidget ScrollWidget/ SwingScrollWidget SeparatorWidget

Provides a transparent surface, comparable to a JGlassPane. Provides a placeholder widget for AWT/Swing components. Provides images to the scene. Provides a label as a widget. Provides an image and a label. Provides connections between widgets, with anchors, control poins, and end points. Provides coil/twist effect, i.e., a convolve filter to a child element. Provides a container for widgets, with visibility and zoom features. Provides a scrollable area, with/ without JScrollBar as scroll bars. Provides a space with thickness and orientation.

As key code, use KeyEvent.VK_keycode without VK_ prefix, as described in Javadoc of org.openide.util.Utilities stringToKey() and keyToString() methods.

Nodes
A Node is a generic model for a business object, which it visualizes within an Explorer View. Each Node can have visual attributes, such as a display name, icon, and actions. The list of Nodes is below, which you can use as is or extend as needed:
Type Node AbstractNode DataNode BeanNode FilterNode Description Base class for representing business objects to the user. The usual base class for Node implementations. Specialized Node class for wrapping a file and displaying it as a Node to the user. Specialized Node class that wraps a JavaBean and presents it to the user as a Node. It also provides simplistic access to property sheets. Specialized Node class that decorates an existing Node by adding/removing features to/from it.

For all the details, see http://bits.netbeans.org/6.8/javadoc/ org-netbeans-api-visual.

Dialogs
The NetBeans Dialogs API provides a number of standard dialogs for displaying standard messages for information, questions (such as Are you sure?, when saving), input, and error messages to the user. Each dialog comes with a standard appearance, buttons, and icons.
Type
Information Dialog Question Dialog Input Dialog

Description
NotifyDescriptor d = new NotifyDescriptor.Message(Text); NotifyDescriptor d = new NotifyDescriptor.Confirmation(Title, Text); NotifyDescriptor d = new NotifyDescriptor.InputLine(Title, Text);

A Node is a container for its own child Nodes. These classes create child Nodes:
ChildFactory Children.Keys Factory for creating child Nodes. Optionally, these can be created asynhronously, that is, when the user expands the Node. Older version of ChildFactory. You should be able to replace any implementation of Children.Keys with ChildFactory.

Add the Dialogs API to your module and then use the table above to create dialogs as follows (in the example below, we display an information dialog):
NotifyDescriptor d = new NotifyDescriptor.Message(Text); DialogDisplayer.getDefault().notify(d);

Children.Array, Children.Map, Children.SortedArray,

For all the details, see http://bits.netbeans.org/6.8/javadoc/ org-openide-dialogs.

These classes are less frequently used and are no longer well supported.
Children.SortedMap:

Explorer Views
Explorer views are Swing components that display Node hierarchies.
BeanTreeView OutlineView PropertySheetView JTree for displaying Nodes. JTree for displaying Nodes, with a JTable for displaying the related Node properties. Property sheet displaying the properties of a Node.

Hot Tip

The Dialogs API also provides a group of Wizard classes for multipage dialogs!

Other Useful NetBeans APIs


Type
org.apache.tools.ant. module.api.support. ActionUtils org.openide.util. ImageUtilities

Description
Used for running Ant targets.

IconView, ListView, ChoiceView, ContextTreeView,

These classes are less frequently used and are no longer well supported.
MenuView, TableView:

Provides useful static methods for manipulation with images/icons, results are cached. Displays URLs, opens browsers, distinguishes embedded vs. external browsers. Integrates visualization of long running tasks with the NetBeans Platform progress bar. Performs asynchronous threads in a dedicated thread pool. Listens to editing changes and activates the Undo and Redo buttons.

For all the details, see http://bits.netbeans.org/6.8/javadoc/ org-openide-explorer.

org.openide.awt.HtmlBrowser.URLDisplayer
org.netbeans.api. progress.ProgressHandle org.openide.util. RequestProcessor org.openide.awt. UndoRedo

Visual Library
The NetBeans visual library is a generic widget and graph library, providing a collection of predefined widgets that integrate well with other NetBeans Platform objects, such as Nodes and windows. Below is the list of widgets provided by this library.
Type
Scene

Description
Provides the root element of the hierarchy of displayed widgets.

Hot Tip

Explore the Utilities API (org.openide.util.jar) for many useful classes that all NetBeans Platform applications can use.

DZone, Inc.

www.dzone.com

Essential NetBeans Platform

NETBEANS PLATFORM GOTCHAS


The following are frequently asked questions, returning over and over again, with their answers:
FAQ
Whats the difference between a NetBeans Platform Application and a Module Suite?

NETBEANS PLATFORM ON-LINE


Technical information on the NetBeans Platform is available on-line in many different forms. The most important of these are listed below:
Site Homepage Tutorials NetBeans API javadoc Blogs FAQ Mailing List Screencast URL
http://platform.netbeans.org http://platform.netbeans.org/tutorials http://bits.netbeans.org/6.8/javadoc/ http://planetnetbeans.org http://wiki.netbeans.org/NetBeansDeveloperFAQ [email protected] http://netbeans.org/platform/lists/dev/archive http://platform.netbeans.org/tutorials/nbm-10-top-apis.html

Answers
The former gives you a subset of the NetBeans Platform, the latter a subset of NetBeans IDE. Use the former when building on the NetBeans Platform, the latter when building on NetBeans IDE. Because you need to add this line to the TopComponent constructor: associateLookup(ExplorerUtils.createLookup(em, getActionMap()); Because your TopComponent is not in editor mode.

Why is my explorer view not synchronized with the Properties window?

I created a palette but it isnt showing when I open the related TopComponent.

This Refcard could not have been made without the technical insights provided by the following: Tim Boudreau, Tim Dudgeon, Jeremy Faden, Laurent Fort, Jesse Glick, Manikantan, Ernie Rael, Antonio Vieiro and Tom Wheeler.

ABOUT THE AUTHORS


Heiko Bck is the author of the well-known The Definitive Guide to NetBeans Platform

RECOMMENDED BOOKS
The Definitive Guide to NetBeans Platform is a thorough and definitive introduction to the NetBeans Platform, covering all its major APIs in detail, with relevant code examples used throughout.

Anton Epple (http://eppleton.sharedhost.de/) is a NetBeans Platform consultant & trainer.

Milo ilhnek is a Java, NetBeans Platform, 3D and AI enthusiast and Czech translator of Heiko Bcks book. Andreas Stefik is an Assistant Professor at Southern Illinois University Edwardsville.

books.dzone.com/books/definitive-guide-netbeans
Rich Client Programming will help you get started with NetBeans module development, master NetBeans key APIs, and learn proven techniques for building reliable desktop software.

BUY NOW

Tom Wheeler (http://www.tomwheeler.com) has worked with NetBeans Platform nearly every day for the past five years and is a consultant, trainer and member of the NetBeans Dream Team. Geertjan Wielenga works on the NetBeans team and is co-author of Rich Client Programming: Plugging into the NetBeans Platform

books.dzone.com/books/richclientprog

BUY NOW

Bro

ugh

t to

you

by...

Professional Cheat Sheets You Can Trust


Exactly what busy developers need: simple, short, and to the point.
James Ward, Adobe Systems
r

#8
z.co m

V is it rz!

E: LUD IN C y TS bilit TEN onsi ON Resp C f in o d Cha man r om C te rpre Inte tor ... ore Itera tor dm dia d an Me rver tho se Me S Ob RN plate TTE Tem
n n n n n n n

ired Insp e by th GoF ller se Best

ign Des
Cha in esp of R
n

rns atte P
ity, con
a re

ld ona McD son Ja By


tinu ed
d th ndle e ha que re le a r doe snt to have ndle st an ith th e ha

Upcoming Titles
Blaze DS Domain Driven Design Virtualization Java Performance Tuning Expression Web Spring Web Flow Continous Integration

Most Popular
Spring Configuration jQuery Selectors Windows Powershell Dependency Injection with EJB 3 Netbeans IDE JavaEditor Getting Started with Eclipse Very First Steps in Flex

ons

ibil

DZone communities deliver over 6 million pages each month to


n

one

more than 3.3 million software developers, architects and decision


z w. d

the e to renc refe listed in ick s cta qu s, a s ttern le Obje s, vide pro n pa DES sab iagram . UT fcard F) desig of Reu le r s re ss d o ABO mp oke ents des cla ttern our (G exa Inv d Pa h lem ign of F worl suc s: E inclu Des cts D ang attern real ern AN This al 23 G P obje enting patt , and a ign uct ch MM in m and tion nstr Des are. Ea ple CO orig m o k rma om to c their im boo Softw nt teC info sed cre Clie the d age nd Con from s: U () ente on, us ma er n led ct cute Ori Com ) ti s bje oup Patt ( +exe low eo lana dec is al nal cute ch larg exp . Th s su atio can be +exe ts. rm bject nship fo Cre jec y an o tio s, the d to rate ob d as ed rela m t eate as Use rith tha be tr bject b ispa ns: lgo ts. m. r it to lly o jec tter many d ge a ive ing syste low aditiona ece n ob ana l Pa al s. R e ra en tr der uest to m betwe ctu twe nt or req ndled in n. sa sed s varia Stru s be an . late catio e ha s: U or in ilitie psu at c invo to b llbacks cture the times Enca quest nsib s th ttern y. d ca stru ling re riant nalit g l Pa d respo ship ng an the hand pose ssin e nctio led at va ueui tion iora n ject Pur k fu roce b as q e ob rela hav hips, a us p lity to e llbac be hand ed. ct Be m th nb na rono s ed ca to need need led fro obje ynch functio t ca any tion s is You ne s need st ut e as the ith tha coup st rela que it is itho e th ar ls w ips Reque y of re be de litat pattern ssing w tation articul nsh or faci Dea e. ould p d en ce Use r sh A hist n latio ed to mman for pro implem ents its ting. pe: pe voke co ec y us Whe ntim s re Sco ue toty The in tual plem is exp the idel que clas Pro e w ilizing e ac ued im ject ed at ru ue job C f th s ar ut Ob with que g to a e que ge o ueue s. By xy bq iven owled at is en rface th han eals me. hm be g Jo Pro kn gorit ct th be c n e: D ile ti inte S r le of al ed ca to have d obje of the er mp cop p rato ut an Exa serv nes ss S at com exec e queue comm Deco Ob confi S Cla e th B d the n . Th for de nge king leto ithin invo hm w Faca cha Sing od tory

PA IGN

l ay an hand sm entia hen ject le to . pot .W ble le ob tern ethod bject be ab pta pat Multip ecific o should acce this if the m up the s sp ents is an ject ntime. see passed be a led plem ks to de to ru of ob e Use hand til co es im e chec ould b set ined at n A s un arent uag hen m being sh im ng er W peat ore p not e la the runt or if it det s re uest som d tion proces e no m req g in metho cep n A e e ar a ndlin e ex ack th ther n ha rown in ndle th ll st until ptio th e ca Exce ion is sm to ha up th tered or ral pt ni ed un ple avio exce mecha n pass enco . xam Beh is a E he tion uest to has ack. W ject q cep st Ob e re e ex call le th nd th hand s to ha ct obje

le hand

que

Download Now
om outc e.

st w

Refcardz.com

re f c

a rd

ef re R

ca

DZone, Inc. 140 Preston Executive Dr. Suite 100 Cary, NC 27513 888.678.0399 919.678.0300

Mo

ISBN-13: 978-1-934238-94-3 ISBN-10: 1-934238-94-5

Get

50795

.com

makers. DZone offers something for everyone, including news,


S

tutorials, cheatsheets, blogs, feature articles, source code and more.


ww
C

Brid

ge

Stra

Bu

r ilde

od Meth plate Tem V r isito

teg

DZone is a developers dream, says PC Magazine. ITY


B S

f in o ty Cha nsibili o Resp d man Com B te posi Com

Ob
or

ject

Beh

avio

ral

OF Copyright 2009 DZone, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, AIN >> CH ace photocopying, or otherwise, without prior written permission of the publisher. Reference: terf ler d <<in
Clie nt () Han uest req ndle +ha Han dle r2

RES

PO

NSIB

IL

succ

ess

Sponsorship Opportunities [email protected]

9 781934 238943
Version 1.0

$7.95

Fac ract Abst r pte Ada

Meth tory Fac t eigh Flyw ter rpre Inte B r rato Ite B r diato Me B to men Me

State

algo

rit

Refcardz Feedback Welcome [email protected]

You might also like