All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.awt.MenuItem

java.lang.Object
   |
   +----java.awt.MenuComponent
           |
           +----java.awt.MenuItem

public class MenuItem
extends MenuComponent
A String item that represents a choice in a menu.


Constructor Index

 o MenuItem()
Constructs a new MenuItem with an empty label and no keyboard shortcut.
 o MenuItem(String)
Constructs a new MenuItem with the specified label and no keyboard shortcut.
 o MenuItem(String, MenuShortcut)
Create a MenuItem with an associated keyboard shortcut.

Method Index

 o addActionListener(ActionListener)
Adds the specified action listener to receive action events from this menu item.
 o addNotify()
Creates the menu item's peer.
 o deleteShortcut()
Delete any MenuShortcut associated with this MenuItem.
 o disable()
Deprecated.
 o disableEvents(long)
Disables the events defined by the specified event mask parameter from being delivered to this menu item.
 o enable()
Deprecated.
 o enable(boolean)
Deprecated.
 o enableEvents(long)
Enables the events defined by the specified event mask parameter to be delivered to this menu item.
 o getActionCommand()
Returns the command name of the action event fired by this menu item.
 o getLabel()
Gets the label for this menu item.
 o getShortcut()
Return the MenuShortcut associated with this MenuItem, or null if none has been specified.
 o isEnabled()
Checks whether the menu item is enabled.
 o paramString()
Returns the String parameter of the menu item.
 o processActionEvent(ActionEvent)
Processes action events occurring on this menu item by dispatching them to any registered ActionListener objects.
 o processEvent(AWTEvent)
Processes events on this menu item.
 o removeActionListener(ActionListener)
Removes the specified action listener so it no longer receives action events from this menu item.
 o setActionCommand(String)
Sets the command name of the action event fired by this menu item.
 o setEnabled(boolean)
Sets whether or not this menu item can be chosen.
 o setLabel(String)
Sets the label to be the specified label.
 o setShortcut(MenuShortcut)
Set this MenuItem's MenuShortcut.

Constructors

 o MenuItem
 public MenuItem()
Constructs a new MenuItem with an empty label and no keyboard shortcut.

 o MenuItem
 public MenuItem(String label)
Constructs a new MenuItem with the specified label and no keyboard shortcut.

Parameters:
label - the label for this menu item. Note that "-" is reserved to mean a separator between menu items.
 o MenuItem
 public MenuItem(String label,
                 MenuShortcut s)
Create a MenuItem with an associated keyboard shortcut.

Parameters:
label - the label for this menu item. Note that "-" is reserved to mean a separator between menu items.
s - the MenuShortcut associated with this MenuItem.

Methods

 o addNotify
 public void addNotify()
Creates the menu item's peer. The peer allows us to modify the appearance of the menu item without changing its functionality.

 o getLabel
 public String getLabel()
Gets the label for this menu item.

 o setLabel
 public synchronized void setLabel(String label)
Sets the label to be the specified label.

Parameters:
label - the label for this menu item
 o isEnabled
 public boolean isEnabled()
Checks whether the menu item is enabled.

 o setEnabled
 public synchronized void setEnabled(boolean b)
Sets whether or not this menu item can be chosen.

Parameters:
b - if true, enables this menu item; otherwise, disables it
 o enable
 public synchronized void enable()
Note: enable() is deprecated. As of JDK version 1.1, replaced by setEnabled(boolean).

 o enable
 public void enable(boolean b)
Note: enable() is deprecated. As of JDK version 1.1, replaced by setEnabled(boolean).

 o disable
 public synchronized void disable()
Note: disable() is deprecated. As of JDK version 1.1, replaced by setEnabled(boolean).

 o getShortcut
 public MenuShortcut getShortcut()
Return the MenuShortcut associated with this MenuItem, or null if none has been specified.

 o setShortcut
 public void setShortcut(MenuShortcut s)
Set this MenuItem's MenuShortcut. If a MenuShortcut is already associated with this MenuItem, it will be replaced.

Parameters:
s - the MenuShortcut to associate with this MenuItem.
 o deleteShortcut
 public void deleteShortcut()
Delete any MenuShortcut associated with this MenuItem.

 o enableEvents
 protected final void enableEvents(long eventsToEnable)
Enables the events defined by the specified event mask parameter to be delivered to this menu item. Event types are automatically enabled when a listener for that type is added to the menu item, therefore this method only needs to be invoked by subclasses of a menu item which desire to have the specified event types delivered to processEvent regardless of whether a listener is registered.

Parameters:
eventsToEnable - the event mask defining the event types
 o disableEvents
 protected final void disableEvents(long eventsToDisable)
Disables the events defined by the specified event mask parameter from being delivered to this menu item.

Parameters:
eventsToDisable - the event mask defining the event types
 o setActionCommand
 public void setActionCommand(String command)
Sets the command name of the action event fired by this menu item. By default this will be set to the label of the menu item.

 o getActionCommand
 public String getActionCommand()
Returns the command name of the action event fired by this menu item.

 o addActionListener
 public synchronized void addActionListener(ActionListener l)
Adds the specified action listener to receive action events from this menu item.

Parameters:
l - the action listener
 o removeActionListener
 public synchronized void removeActionListener(ActionListener l)
Removes the specified action listener so it no longer receives action events from this menu item.

Parameters:
l - the action listener
 o processEvent
 protected void processEvent(AWTEvent e)
Processes events on this menu item. If the event is an ActionEvent, it invokes the handleActionEvent method. NOTE: Menu items currently only support action events.

Parameters:
e - the event
Overrides:
processEvent in class MenuComponent
 o processActionEvent
 protected void processActionEvent(ActionEvent e)
Processes action events occurring on this menu item by dispatching them to any registered ActionListener objects. NOTE: This method will not be called unless action events are enabled for this component; this happens when one of the following occurs: a) An ActionListener object is registered via addActionListener() b) Action events are enabled via enableEvents()

Parameters:
e - the action event
See Also:
enableEvents
 o paramString
 public String paramString()
Returns the String parameter of the menu item.

Overrides:
paramString in class MenuComponent

All Packages  Class Hierarchy  This Package  Previous  Next  Index