From Pain to Gain: Swing and the NetBeans Platform in the Real World

Tags:
The Window System API

The NetBeans Platform provides a specific windowing component named TopComponent. This component models a rectangular portion of the main window, which can be resized and docked in different areas of the screen (these areas are called “modes”). For instance, the Explorer mode is a vertical column at the left side; the Properties mode is a vertical column at the right side; the Editor mode is the remaining space at the center (see Figure 9).

Figure 9. Modes in the main window of blueMarine – “strip” is a custom mode; each mode contains a TopComponent.

Also, a TopComponent can be activated or deactivated, has its own mechanism for keeping persistent state (which is automatically restored on restart), and can request attention by flashing its tab.

Docking areas can be resized with the mouse, or programmatically. You can assign TopComponents to different areas by dragging them with the mouse or through code. You can define your own docking areas as well. For instance, I needed a component called “Film Strip” that should be placed at the bottom of the window. So I defined a docking area called “strip” and bound the Film Strip to it (see Figure 9 again).

While this flexibility is great for some types of applications, such as an IDE or a CAD system, so much control could be distracting to some classes of users. For blueMarine I prefer not to have such flexible docking: a fixed scheme is used, offering just a bit of control through menu commands that let you swap the components in the Explorer and Properties modes.

The tabs and the control code which allows docking with the mouse has been removed in blueMarine by specifying a special TabDisplayerUI (the visual component for each mode). I implemented programmatic control with the code in Listing 6.

Listing 6. Programmatic component docking.

    TopComponent topComponent = ...;
String newMode = "explorer";
Mode targetMode = WindowManager.getDefault().findMode(newMode);

if (targetMode != null) {
component.close();
targetMode.dockInto(component);
component.open();
component.requestVisible();
}

Note: Indeed it was not hard at all to implement the TabDisplayerUI trick, but only because I discovered the solution on Geertjan Wielenga’s blog; without that help it would have taken much longer. I found that programmers can enjoy excellent support from the NetBeans community, both in the mailing list and in the evangelists’ blogs – I recommend you to bookmark these!

0
Average: 5 (1 vote)

(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

thanks for your post.perhaps you will like abercrombie,ed hardy,mortgage rates,tiffanysanded hardy Is not it?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.