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
    method MenuItem() public 
Constructs a new MenuItem with an empty label and no keyboard shortcut.

 o MenuItem
    method MenuItem(label=String) public 
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
    method MenuItem(label=String, -
                    s=MenuShortcut) public 
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
    method addNotify()  public     
Creates the menu item's peer. The peer allows us to modify the appearance of the menu item without changing its functionality.

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

 o setLabel
    method setLabel(label=String)  public    protect 
Sets the label to be the specified label.

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

 o setEnabled
    method setEnabled(b=boolean)  public    protect 
Sets whether or not this menu item can be chosen.

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

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

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

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

 o setShortcut
    method setShortcut(s=MenuShortcut)  public     
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
    method deleteShortcut()  public     
Delete any MenuShortcut associated with this MenuItem.

 o enableEvents
    method enableEvents(eventsToEnable=long)  Inheritable   final  
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
    method disableEvents(eventsToDisable=long)  Inheritable   final  
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
    method setActionCommand(command=String)  public     
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
    method getActionCommand() returns String public     
Returns the command name of the action event fired by this menu item.

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

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

Parameters:
l - the action listener
 o processEvent
    method processEvent(e=AWTEvent)  Inheritable     
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
    method processActionEvent(e=ActionEvent)  Inheritable     
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
    method paramString() returns String public     
Returns the String parameter of the menu item.

Overrides:
paramString in class MenuComponent

All Packages  Class Hierarchy  This Package  Previous  Next  Index