java.awt
Class MenuItem
java.lang.Object
|
+--java.awt.MenuComponent
|
+--java.awt.MenuItem
All Implemented Interfaces:
Serializable, Serializable
This class represents an item in a menu.
Author:- Aaron M. Renn (arenn@urbanophile.com)
MenuItem
public MenuItem()
Initializes a new instance of MenuItem
with no label
and no shortcut.
MenuItem
public MenuItem(java.lang.String label)
Initializes a new instance of MenuItem
with the specified
label and no shortcut.
Parameters:
MenuItem
public MenuItem(java.lang.String label, java.awt.MenuShortcut shortcut)
Initializes a new instance of MenuItem
with the specified
label and shortcut.
Parameters:
addActionListener
public synchronized void addActionListener(java.awt.event.ActionListener listener)
Adds the specified listener to the list of registered action listeners
for this component.
Parameters:
addNotify
public void addNotify()
Creates the native peer for this object.
deleteShortcut
public void deleteShortcut()
Deletes the shortcut for this menu item if one exists. This must be
done before the native peer is created.
disable
public void disable()
Disables this menu item.
disableEvents
protected final void disableEvents(long events)
Disables the specified events.
Parameters:
enable
public void enable()
Enables this menu item.
enable
public void enable(boolean enabled)
Sets the enabled status of this menu item.
Parameters:
enableEvents
protected final void enableEvents(long events)
Enables the specified events. This is done automatically when a
listener is added and does not normally need to be done by
application code.
Parameters:
getActionCommand
public String getActionCommand()
Returns the name of the action command in the action events
generated by this menu item.
Returns:
getActionListeners
public synchronized ActionListener[] getActionListeners()
getLabel
public String getLabel()
Returns the label for this menu item, which may be null
.
Returns:
- The label for this menu item.
getListeners
public EventListener[] getListeners(java.lang.Class listenerType)
Returns all registered EventListers of the given listenerType.
listenerType must be a subclass of EventListener, or a
ClassClassException is thrown.
Since:Parameters:
getShortcut
public MenuShortcut getShortcut()
Returns the shortcut for this menu item, which may be null
.
Returns:
- The shortcut for this menu item.
isEnabled
public boolean isEnabled()
Tests whether or not this menu item is enabled.
Returns:
true
if this menu item is enabled, false
otherwise.
paramString
public String paramString()
Returns a debugging string for this object.
Returns:
- A debugging string for this object.
processActionEvent
protected void processActionEvent(java.awt.event.ActionEvent event)
Processes the specified event by dispatching it to any registered listeners.
Parameters:
processEvent
protected void processEvent(java.awt.AWTEvent event)
Processes the specified event by calling processActionEvent()
if it is an instance of ActionEvent
.
Parameters:
removeActionListener
public synchronized void removeActionListener(java.awt.event.ActionListener l)
Parameters:
setActionCommand
public void setActionCommand(java.lang.String actionCommand)
Sets the name of the action command in the action events generated by
this menu item.
Parameters:
setEnabled
public synchronized void setEnabled(boolean enabled)
Sets the enabled status of this menu item.
Parameters:
setLabel
public synchronized void setLabel(java.lang.String label)
This method sets the label for this menu to the specified value.
Parameters:
setShortcut
public void setShortcut(java.awt.MenuShortcut shortcut)
Sets the shortcut for this menu item to the specified value. This
must be done before the native peer is created.
Parameters: