Menu object is a pull-down menu component
that is deployed from a menu bar.
A menu can optionally be a tear-off menu. A tear-off menu can be opened and dragged away from its parent menu bar or menu. It remains on the screen after the mouse button has been released. The mechanism for tearing off a menu is platform dependent, since the look and feel of the tear-off menu is determined by its peer. On platforms that do not support tear-off menus, the tear-off property is ignored.
Each item in a menu must belong to the MenuItem
class. It can be an instance of MenuItem, a submenu
(an instance of Menu), or a check box (an instance of
CheckboxMenuItem).
java.awt.MenuItem , java.awt.CheckboxMenuItem
| Modifier and Type | Class and Description |
|---|---|
| protected class | Menu.
Inner class of Menu used to provide default support for accessibility. |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | base
Hides java. |
| pack-priv volatile boolean | isHelpMenu
This field will be set to |
| private final Vector | items
A vector of the items that will be part of the Menu. |
| private int | menuSerializedDataVersion
The menu serialized Data Version. |
| private static int | |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1 for interoperability.
|
| private final boolean | tearOff
This field indicates whether the menu has the tear of property or not. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public MenuItem | |
| public void | |
| public void | |
| public void | |
| pack-priv String | constructComponentName()
Overrides java. Construct a name for this MenuComponent. |
| public int | Returns: the number of items in this menu
Deprecated
As of JDK version 1.1,
replaced by
getItemCount().
Returns the number of items in this menu. |
| pack-priv final int | |
| pack-priv void | |
| pack-priv int | getAccessibleChildIndex(MenuComponent child)
Overrides java. Defined in MenuComponent. |
| public AccessibleContext | Returns: an AccessibleAWTMenu that serves as the AccessibleContext of this MenuOverrides java. Implements javax. Gets the AccessibleContext associated with this Menu. |
| public MenuItem | Returns: the item located at the specified index.the position of the item to be returned. index)Gets the item located at the specified index of this menu. |
| public int | |
| pack-priv final MenuItem | |
| pack-priv MenuItem | |
| pack-priv boolean | |
| private static native void | |
| public void | |
| public void | |
| public void | insertSeparator(int
the position at which the
menu separator should be inserted. index)Inserts a separator at the specified position. |
| public boolean | Returns: true if this is a tear-off menu;
false otherwise.Indicates whether this menu is a tear-off menu. |
| public String | Returns: the parameter string of this menuOverrides java. Returns a string representing the state of this |
| private void | readObject(ObjectInputStream
the s)ObjectInputStream to readHides java. Reads the |
| public void | remove(int
the position of the item to be removed. index)Removes the menu item at the specified index from this menu. |
| public void | remove(MenuComponent
the item to be removed from the menu.
If item)item is null
or is not in this menu, this method does
nothing.Implements java. Removes the specified menu item from this menu. |
| public void | |
| public void | |
| pack-priv synchronized Enumeration | |
| private void | writeObject(ObjectOutputStream
the s)ObjectOutputStream to writeHides java. Writes default serializable fields to stream. |
| base | back to summary |
|---|---|
| private static final String base Hides java. | |
| isHelpMenu | back to summary |
|---|---|
| pack-priv volatile boolean isHelpMenu This field will be set to | |
| items | back to summary |
|---|---|
| private final Vector<MenuItem> items A vector of the items that will be part of the Menu.
| |
| menuSerializedDataVersion | back to summary |
|---|---|
| private int menuSerializedDataVersion The menu serialized Data Version. | |
| nameCounter | back to summary |
|---|---|
| private static int nameCounter | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. Use serialVersionUID from JDK 1.1 for interoperability. | |
| tearOff | back to summary |
|---|---|
| private final boolean tearOff This field indicates whether the menu has the
tear of property or not. It will be set to
| |
| Menu | back to summary |
|---|---|
| public Menu() throws HeadlessException Constructs a new menu with an empty label. This menu is not a tear-off menu.
| |
| Menu | back to summary |
|---|---|
| public Menu(String label) throws HeadlessException Constructs a new menu with the specified label. This menu is not a tear-off menu.
| |
| Menu | back to summary |
|---|---|
| public Menu(String label, boolean tearOff) throws HeadlessException Constructs a new menu with the specified label, indicating whether the menu can be torn off. Tear-off functionality may not be supported by all implementations of AWT. If a particular implementation doesn't support tear-off menus, this value is silently ignored.
| |
| add | back to summary |
|---|---|
| public MenuItem add(MenuItem mi) Adds the specified menu item to this menu. If the menu item has been part of another menu, removes it from that menu.
| |
| add | back to summary |
|---|---|
| public void add(String label) Adds an item with the specified label to this menu.
| |
| addNotify | back to summary |
|---|---|
| public void addNotify() Overrides java. Creates the menu's peer. The peer allows us to modify the appearance of the menu without changing its functionality. | |
| addSeparator | back to summary |
|---|---|
| public void addSeparator() Adds a separator line, or a hyphen, to the menu at the current position.
| |
| constructComponentName | back to summary |
|---|---|
| pack-priv String constructComponentName() Overrides java. Construct a name for this MenuComponent. Called by getName() when the name is null. | |
| countItems | back to summary |
|---|---|
| public int countItems()
Deprecated As of JDK version 1.1,
replaced by Returns the number of items in this menu.
| |
| countItemsImpl | back to summary |
|---|---|
| pack-priv final int countItemsImpl() | |
| deleteShortcut | back to summary |
|---|---|
| pack-priv void deleteShortcut(MenuShortcut s) Overrides java. | |
| getAccessibleChildIndex | back to summary |
|---|---|
| pack-priv int getAccessibleChildIndex(MenuComponent child) Overrides java. Defined in MenuComponent. Overridden here. | |
| getAccessibleContext | back to summary |
|---|---|
| public AccessibleContext getAccessibleContext() Overrides java. Implements javax. Gets the AccessibleContext associated with this Menu. For menus, the AccessibleContext takes the form of an AccessibleAWTMenu. A new AccessibleAWTMenu instance is created if necessary.
| |
| getItem | back to summary |
|---|---|
| public MenuItem getItem(int index) Gets the item located at the specified index of this menu.
| |
| getItemCount | back to summary |
|---|---|
| public int getItemCount() Get the number of items in this menu.
| |
| getItemImpl | back to summary |
|---|---|
| pack-priv final MenuItem getItemImpl(int index) | |
| getShortcutMenuItem | back to summary |
|---|---|
| pack-priv MenuItem getShortcutMenuItem(MenuShortcut s) Overrides java. | |
| handleShortcut | back to summary |
|---|---|
| pack-priv boolean handleShortcut(KeyEvent e) Overrides java. | |
| initIDs | back to summary |
|---|---|
| private static native void initIDs() Hides java. Initialize JNI field and method IDs | |
| insert | back to summary |
|---|---|
| public void insert(MenuItem menuitem, int index) Inserts a menu item into this menu at the specified position.
| |
| insert | back to summary |
|---|---|
| public void insert(String label, int index) Inserts a menu item with the specified label into this menu
at the specified position. This is a convenience method for
| |
| insertSeparator | back to summary |
|---|---|
| public void insertSeparator(int index) Inserts a separator at the specified position.
| |
| isTearOff | back to summary |
|---|---|
| public boolean isTearOff() Indicates whether this menu is a tear-off menu. Tear-off functionality may not be supported by all implementations of AWT. If a particular implementation doesn't support tear-off menus, this value is silently ignored.
| |
| paramString | back to summary |
|---|---|
| public String paramString() Overrides java. Returns a string representing the state of this
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException, HeadlessException Hides java. Reads the
| |
| remove | back to summary |
|---|---|
| public void remove(int index) Removes the menu item at the specified index from this menu.
| |
| remove | back to summary |
|---|---|
| public void remove(MenuComponent item) Implements java. Removes the specified menu item from this menu.
| |
| removeAll | back to summary |
|---|---|
| public void removeAll() Removes all items from this menu.
| |
| removeNotify | back to summary |
|---|---|
| public void removeNotify() Overrides java. Removes the menu's peer. The peer allows us to modify the appearance of the menu without changing its functionality. | |
| shortcuts | back to summary |
|---|---|
| pack-priv synchronized Enumeration | |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream s) throws IOException Hides java. Writes default serializable fields to stream.
| |
This class implements accessibility support for the
Menu class. It provides an implementation of the
Java Accessibility API appropriate to menu user-interface elements.
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Hides java. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public AccessibleRole | Returns: an instance of AccessibleRole describing the role of the objectOverrides java. Get the role of this object. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. Use serialVersionUID from JDK 1.3 for interoperability. | |
| AccessibleAWTMenu | back to summary |
|---|---|
| protected AccessibleAWTMenu() Constructs an | |
| getAccessibleRole | back to summary |
|---|---|
| public AccessibleRole getAccessibleRole() Overrides java. Get the role of this object.
| |