|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.MenuComponent
java.awt.MenuItem
public class MenuItem
This class represents an item in a menu.
Nested Class Summary | |
---|---|
protected class |
MenuItem.AccessibleAWTMenuItem
|
Nested classes/interfaces inherited from class java.awt.MenuComponent |
---|
MenuComponent.AccessibleAWTMenuComponent |
Constructor Summary | |
---|---|
MenuItem()
Initializes a new instance of MenuItem with no label
and no shortcut. |
|
MenuItem(String label)
Initializes a new instance of MenuItem with the specified
label and no shortcut. |
|
MenuItem(String label,
MenuShortcut shortcut)
Initializes a new instance of MenuItem with the specified
label and shortcut. |
Method Summary | ||
---|---|---|
void |
addActionListener(ActionListener listener)
Adds the specified listener to the list of registered action listeners for this component. |
|
void |
addNotify()
Creates the native peer for this object. |
|
void |
deleteShortcut()
Deletes the shortcut for this menu item if one exists. |
|
void |
disable()
Deprecated. This method is deprecated in favor of setEnabled() . |
|
protected void |
disableEvents(long events)
Disables the specified events. |
|
void |
enable()
Deprecated. This method is deprecated in favor of setEnabled() . |
|
void |
enable(boolean enabled)
Deprecated. This method is deprecated in favor of setEnabled() . |
|
protected void |
enableEvents(long events)
Enables the specified events. |
|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this MenuItem . |
|
String |
getActionCommand()
Returns the name of the action command in the action events generated by this menu item. |
|
ActionListener[] |
getActionListeners()
|
|
String |
getLabel()
Returns the label for this menu item, which may be null . |
|
|
getListeners(Class<T> listenerType)
Returns all registered EventListers of the given listenerType. |
|
MenuShortcut |
getShortcut()
Returns the shortcut for this menu item, which may be null . |
|
boolean |
isEnabled()
Tests whether or not this menu item is enabled. |
|
String |
paramString()
Returns a debugging string for this object. |
|
protected void |
processActionEvent(ActionEvent event)
Processes the specified event by dispatching it to any registered listeners. |
|
protected void |
processEvent(AWTEvent event)
Processes the specified event by calling processActionEvent()
if it is an instance of ActionEvent . |
|
void |
removeActionListener(ActionListener l)
|
|
void |
setActionCommand(String actionCommand)
Sets the name of the action command in the action events generated by this menu item. |
|
void |
setEnabled(boolean enabled)
Sets the enabled status of this menu item. |
|
void |
setLabel(String label)
This method sets the label for this menu to the specified value. |
|
void |
setShortcut(MenuShortcut shortcut)
Sets the shortcut for this menu item to the specified value. |
Methods inherited from class java.awt.MenuComponent |
---|
dispatchEvent, getFont, getName, getParent, getPeer, getTreeLock, postEvent, removeNotify, setFont, setName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MenuItem()
MenuItem
with no label
and no shortcut.
public MenuItem(String label)
MenuItem
with the specified
label and no shortcut.
label
- The label for this menu item.public MenuItem(String label, MenuShortcut shortcut)
MenuItem
with the specified
label and shortcut.
label
- The label for this menu item.shortcut
- The shortcut for this menu item.Method Detail |
---|
public String getLabel()
null
.
public void setLabel(String label)
label
- The new label for this menu item.public boolean isEnabled()
true
if this menu item is enabled, false
otherwise.public void setEnabled(boolean enabled)
enabled
- true
to enable this menu item,
false
otherwise.public void enable(boolean enabled)
setEnabled()
.
enabled
- true
to enable this menu item,
false
otherwise.public void enable()
setEnabled()
.
public void disable()
setEnabled()
.
public MenuShortcut getShortcut()
null
.
public void setShortcut(MenuShortcut shortcut)
shortcut
- The new shortcut for this menu item.public void deleteShortcut()
public String getActionCommand()
public void setActionCommand(String actionCommand)
actionCommand
- The new action command name.protected final void enableEvents(long events)
events
- The events to enable, which should be the bit masks
from AWTEvent
.protected final void disableEvents(long events)
events
- The events to enable, which should be the bit masks
from AWTEvent
.public void addNotify()
public void addActionListener(ActionListener listener)
listener
- The listener to add.public void removeActionListener(ActionListener l)
public ActionListener[] getActionListeners()
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
protected void processEvent(AWTEvent event)
processActionEvent()
if it is an instance of ActionEvent
.
processEvent
in class MenuComponent
event
- The event to process.protected void processActionEvent(ActionEvent event)
event
- The event to process.public String paramString()
paramString
in class MenuComponent
public AccessibleContext getAccessibleContext()
MenuItem
.
The context is created, if necessary.
getAccessibleContext
in interface Accessible
getAccessibleContext
in class MenuComponent
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |