O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dynamically Modifying Menus

So far, we have modified menus before they are created, by adding items to them. Sometimes it is necessary to modify a menu after it is created.

The SelfModifyingMenu illustrated in Figure 17-7 contains an item that which is either enabled or and disabled by the menu item above it. SelfModifyingMenu also contains two menu items for adding an item and removing the last item added to the menu.

Figure 17-7. A Self-Modifying Menu. The top pair of pictures show the “Enable/Disable Me” item grayed out. The bottom pair of pictures show a menu item added to the menu. Tear-off menus are used to show the different states of the self-modifying menu.

Example 17-10 lists the SelfModifyingMenu class.

Example 17-10. SelfModifyingMenu ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required