GeezerVison is showing docs.oracle.com — MenuItem (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
-
-
Nested Class Summary
Nested Classes
| Modifier and Type |
Class |
Description |
protected class |
MenuItem.AccessibleAWTMenuItem |
Inner class of MenuItem used to provide default support for
accessibility.
|
-
Constructor Summary
Constructors
| Constructor |
Description |
MenuItem() |
Constructs a new MenuItem with an empty label and no keyboard
shortcut.
|
MenuItem(String label) |
Constructs a new MenuItem with the specified label
and no keyboard shortcut.
|
MenuItem(String label,
MenuShortcut s) |
Create a menu item with an associated keyboard shortcut.
|
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods
| Modifier and Type |
Method |
Description |
void |
addActionListener(ActionListener l) |
Adds the specified action listener to receive action events
from this menu item.
|
void |
addNotify() |
Creates the menu item's peer.
|
void |
deleteShortcut() |
Delete any MenuShortcut object associated
with this menu item.
|
void |
disable() |
Deprecated.
As of JDK version 1.1,
replaced by setEnabled(boolean).
|
protected void |
disableEvents(long eventsToDisable) |
Disables event delivery to this menu item for events
defined by the specified event mask parameter.
|
void |
enable() |
Deprecated.
As of JDK version 1.1,
replaced by setEnabled(boolean).
|
void |
enable(boolean b) |
Deprecated.
As of JDK version 1.1,
replaced by setEnabled(boolean).
|
protected void |
enableEvents(long eventsToEnable) |
Enables event delivery to this menu item for events
to be defined by the specified event mask parameter
|
AccessibleContext |
getAccessibleContext() |
Gets the AccessibleContext associated with this MenuItem.
|
String |
getActionCommand() |
Gets the command name of the action event that is fired
by this menu item.
|
ActionListener[] |
getActionListeners() |
Returns an array of all the action listeners
registered on this menu item.
|
String |
getLabel() |
Gets the label for this menu item.
|
<T extends EventListener> T[] |
getListeners(Class<T> listenerType) |
Returns an array of all the objects currently registered
as FooListeners
upon this MenuItem.
|
MenuShortcut |
getShortcut() |
Get the MenuShortcut object associated with this
menu item,
|
boolean |
isEnabled() |
Checks whether this menu item is enabled.
|
String |
paramString() |
Returns a string representing the state of this MenuItem.
|
protected void |
processActionEvent(ActionEvent e) |
Processes action events occurring on this menu item,
by dispatching them to any registered
ActionListener objects.
|
protected void |
processEvent(AWTEvent e) |
Processes events on this menu item.
|
void |
removeActionListener(ActionListener l) |
Removes the specified action listener so it no longer receives
action events from this menu item.
|
void |
setActionCommand(String command) |
Sets the command name of the action event that is fired
by this menu item.
|
void |
setEnabled(boolean b) |
Sets whether or not this menu item can be chosen.
|
void |
setLabel(String label) |
Sets the label for this menu item to the specified label.
|
void |
setShortcut(MenuShortcut s) |
Set the MenuShortcut object associated with this
menu item.
|
-
Methods inherited from class java.awt.MenuComponent
dispatchEvent, getFont, getName, getParent, getPeer, getTreeLock, postEvent, removeNotify, setFont, setName, toString
-
-
Constructor Detail
-
MenuItem
public MenuItem(String label)
throws HeadlessException
Constructs a new MenuItem with the specified label
and no keyboard shortcut. Note that use of "-" in
a label is reserved to indicate a separator between
menu items. By default, all menu items except for
separators are enabled.
- Parameters:
label - the label for this menu item.
- Throws:
HeadlessException - if GraphicsEnvironment.isHeadless()
returns true.
- Since:
- JDK1.0
- See Also:
GraphicsEnvironment.isHeadless()
-
MenuItem
public MenuItem(String label,
MenuShortcut s)
throws HeadlessException
Create a menu item with an associated keyboard shortcut.
Note that use of "-" in a label is reserved to indicate
a separator between menu items. By default, all menu
items except for separators are enabled.
- Parameters:
label - the label for this menu item.
s - the instance of MenuShortcut
associated with this menu item.
- Throws:
HeadlessException - if GraphicsEnvironment.isHeadless()
returns true.
- Since:
- JDK1.1
- See Also:
GraphicsEnvironment.isHeadless()
-
Method Detail
-
enable
@Deprecated
public void enable(boolean b)
Deprecated. As of JDK version 1.1,
replaced by setEnabled(boolean).
-
disable
@Deprecated
public void disable()
Deprecated. As of JDK version 1.1,
replaced by setEnabled(boolean).
-
setShortcut
public void setShortcut(MenuShortcut s)
Set the MenuShortcut object associated with this
menu item. If a menu shortcut is already associated with
this menu item, it is replaced.
- Parameters:
s - the menu shortcut to associate
with this menu item.
- Since:
- JDK1.1
- See Also:
getShortcut()
-
paramString
public String paramString()
Returns a string representing the state of this MenuItem.
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 MenuComponent
- Returns:
- the parameter string of this menu item
-
getAccessibleContext
public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this MenuItem.
For menu items, the AccessibleContext takes the form of an
AccessibleAWTMenuItem.
A new AccessibleAWTMenuItem instance is created if necessary.
- Specified by:
getAccessibleContext in interface Accessible
- Overrides:
getAccessibleContext in class MenuComponent
- Returns:
- an AccessibleAWTMenuItem that serves as the
AccessibleContext of this MenuItem
- 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.
|