![]() ![]() |
![]() |
![]() ![]() ![]() ![]() |
![]() |
Swing implements menus using the JMenu class, which subclasses JMenuItem.
A JMenu object works in association with three other Swing classes: JMenuBar, JMenuItem and JPopupMenu. When the user of your application selects a menu item from a menu (in the manner dictated by the look and feel being used), Swing displays a JPopupMenu. While a menu is posted, the user can interact with the items on the menu, or can cancel the menu (in the manner designated by the current look and feel).
Comprehensive documentation for the Swing menu system -- including JMenu, JMenuItem, JMenuBar, and JPopupMenu -- is currently under development. In this document, the individual components of the Swing menu system are briefly described in detail in their own specifications. For general information about menus and how they work in the Menu system as a whole, see the specification titled The Swing Menu System. Consult the menu-related JavaDoc APIs for current details.
Swing supports (or will support) the following features of menus:
The Swing API for menus is a superset of the 1.1.1 API.
Also note that it is now possible to add an Action to a menu. When you do that, a properly configured MenuItem is generated.
JMenu()
JMenu(String)
JMenu(String, boolean)
void add(String)
void add(JMenuItem)
void add(JMenu)
void add(Action)
void addSeparator()
void insert(String, int)
void remove(JMenuItem)
void remove(Action)
void remove(int)
void removeAll()
MenuItem getItem(int) // How should this be now that other child types exist?
int getItemCount()
boolean isTearOff()
String paramString()
New methods introduced in Swing include the following:
void setLabelShown(String)
void addMenuListener(MenuListener)
void removeMenuListener(MenuListener)
The following methods have been removed in Swing:
addNotify()
countItems()
removeNotify()

Version 0.5. Last modified 10/1/97.
Copyright © 1995-97 Sun
Microsystems, Inc. All Rights Reserved.