Java Reference
In-Depth Information
FIGURE 18-7
How It Works
This works much as before but with some embroidery to the GUI. The menu items in the drop-downs
have accelerator keys that are shown on the menu items. You can see that the corresponding letter in the
menu item text has been underlined. You can access any menu using the mouse, or you can go directly
to the menu item using the accelerator key combination. The appropriate default menu item is selected in
the Elements and Color menus.
If you try out the color menus either by selecting from the drop-down or using the accelerator you should
see the background color change. If it doesn't, there's something wrong somewhere. After you have veri-
fied the color menus work, you can delete the statement that sets the background color from the ac-
tionPerformed() method in the ColorAction class. Now that you have the menus set up using Action
objects, you are ready to tackle the next stage, adding a toolbar to the Sketcher application.
ADDING A TOOLBAR
A toolbar is a bar in an application window, usually positioned at the top edge of the content pane below the
menu bar, that contains buttons that provide more direct routes to menu options. You could add a toolbar to
the Sketcher program for the menu items that are likely to be most popular. Just so that you know where you
are heading, the kind of toolbar you end up with ultimately is shown in Figure 18-8 .
FIGURE 18-8
 
 
 
Search WWH ::




Custom Search