GeezerVison is showing docs.oracle.com — Menu (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
-
-
Nested Class Summary
Nested Classes
| Modifier and Type |
Class |
Description |
protected class |
Menu.AccessibleAWTMenu |
Inner class of Menu used to provide default support for
accessibility.
|
-
Constructor Summary
Constructors
| Constructor |
Description |
Menu() |
Constructs a new menu with an empty label.
|
Menu(String label) |
Constructs a new menu with the specified label.
|
Menu(String label,
boolean tearOff) |
Constructs a new menu with the specified label,
indicating whether the menu can be torn off.
|
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods
| Modifier and Type |
Method |
Description |
MenuItem |
add(MenuItem mi) |
Adds the specified menu item to this menu.
|
void |
add(String label) |
Adds an item with the specified label to this menu.
|
void |
addNotify() |
Creates the menu's peer.
|
void |
addSeparator() |
Adds a separator line, or a hypen, to the menu at the current position.
|
int |
countItems() |
Deprecated.
As of JDK version 1.1,
replaced by getItemCount().
|
AccessibleContext |
getAccessibleContext() |
Gets the AccessibleContext associated with this Menu.
|
MenuItem |
getItem(int index) |
Gets the item located at the specified index of this menu.
|
int |
getItemCount() |
Get the number of items in this menu.
|
void |
insert(MenuItem menuitem,
int index) |
Inserts a menu item into this menu
at the specified position.
|
void |
insert(String label,
int index) |
Inserts a menu item with the specified label into this menu
at the specified position.
|
void |
insertSeparator(int index) |
Inserts a separator at the specified position.
|
boolean |
isTearOff() |
Indicates whether this menu is a tear-off menu.
|
String |
paramString() |
Returns a string representing the state of this Menu.
|
void |
remove(int index) |
Removes the menu item at the specified index from this menu.
|
void |
remove(MenuComponent item) |
Removes the specified menu item from this menu.
|
void |
removeAll() |
Removes all items from this menu.
|
void |
removeNotify() |
Removes the menu's peer.
|
-
Methods inherited from class java.awt.MenuItem
addActionListener, deleteShortcut, disable, disableEvents, enable, enable, enableEvents, getActionCommand, getActionListeners, getLabel, getListeners, getShortcut, isEnabled, processActionEvent, processEvent, removeActionListener, setActionCommand, setEnabled, setLabel, setShortcut
-
-
Method Detail
-
insert
public void insert(MenuItem menuitem,
int index)
Inserts a menu item into this menu
at the specified position.
- Parameters:
menuitem - the menu item to be inserted.
index - the position at which the menu
item should be inserted.
- Throws:
IllegalArgumentException - if the value of
index is less than zero
- Since:
- JDK1.1
- See Also:
add(java.lang.String),
add(java.awt.MenuItem)
-
insert
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
insert(menuItem, index).
- Parameters:
label - the text on the item
index - the position at which the menu item
should be inserted
- Throws:
IllegalArgumentException - if the value of
index is less than zero
- Since:
- JDK1.1
- See Also:
add(java.lang.String),
add(java.awt.MenuItem)
-
addSeparator
public void addSeparator()
Adds a separator line, or a hypen, to the menu at the current position.
- See Also:
insertSeparator(int)
-
paramString
public String paramString()
Returns a string representing the state of this Menu.
This method is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null.
- Overrides:
paramString in class MenuItem
- Returns:
- the parameter string of this menu
-
getAccessibleContext
public AccessibleContext getAccessibleContext()
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.
- Specified by:
getAccessibleContext in interface Accessible
- Overrides:
getAccessibleContext in class MenuItem
- Returns:
- an AccessibleAWTMenu that serves as the
AccessibleContext of this Menu
- Since:
- 1.3
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|