From Pain to Gain: Swing and the NetBeans Platform in the Real World
The Power of the NetBeans Platform
Now that you know the origins of
blueMarine, I’ll give an overview of the many benefits that the NetBeans Platform and Swing
brought to its development, as well as some problems I faced and how I solved
them.
First point: it’s Swing!
To me, the fact that the NetBeans Platform is based on regular Swing is a huge advantage over competitors such as Eclipse RCP. If you look around, you can find a much broader choice of Swing components (including “cool” ones which implement animations and effects).
I concretely realized this advantage last June, when Joshua Marinacci released the source of an Aerith Swing component capable of rendering maps, named JXMapViewer (Aerith was one of the hottest demos at JavaOne 2006). I had been waiting for that moment for several weeks, as one of the features of blueMarine is geo-tagging (associating a geographical position to each photo so they can be shown over a map). Integrating JXMapViewer into blueMarine required just a few hours of work; you can see the result in Figure 3. The Swing choice was indeed rewarding.
![]() |
Figure 3. The Map Viewer with geo-tagged photos uses the JXMapViewer component. |
The Module System
A NetBeans Platform application is naturally organized into modules – in fact, it’s a set of modules bound together. Each module has a name, a set of version tags, its own classpath, and a list of declared dependencies. The developer can control which subset of the public classes is exposed to other modules, and the NetBeans Platform enforces the dependencies among modules (for instance, preventing a module to be installed if any of the required modules is not present or is too old).
Furthermore, an application can be extended at a later time by publishing new modules packed in nbm files, and users can set up their own “update center” for downloading updates from the Internet. Individual modules can be digitally signed and the system automatically pops up their license for approval if required.
The blueMarine project takes full
advantage of this organization. The core APIs of the application are defined by
a relatively small set of modules implementing a workspace manager, photo and
thumbnail management and simple thumbnail and photo viewers. The more advanced
features, such as the Catalog, the Gallery Manager, and geo-tagging
functionality, including the Map Viewer, are implemented in separate and mostly
independent modules that act as “clients” of the core APIs.
DataObjects, Nodes and ExplorerManagers
ExplorerManagers, Nodes and DataObjects are probably the most useful APIs in the NetBeans Platform. With DataObjects you can implement your application-specific entities that are mapped to a file on disk. For instance, blueMarine’s basic entity is PhotoDataObject, which represents a photo in the database.
While DataObjects contain all the status and behavior of your entities, Nodes can be bound to them for visualization purposes. They can also be aggregated in many different ways (as collections or graphs). The NetBeans Platform provides GUI components, such as tables and lists, which can use a set of Node objects as their model; among the most common are BeanTreeView, ContextTreeView, and ListView. Finally, an ExplorerManager controls selections and tree navigation.
Yes, this is nothing more than a sophisticated MVC implementation (see Figure 4), but an implementation where a lot of boilerplate code has been already written for you. For instance, the NetBeans Platform APIs take care of things like drag-and-drop support (with such fine details as visual cues during the drag operation), cut-and-paste operations, and context menus.
![]() |
Figure 4. NetBeans MVC components. |
- Login or register to post comments
- 16644 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)












Comments
jiji530 replied on Fri, 2009/06/26 - 8:29pm