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.
-
MenuItem()
-
Constructs a new MenuItem with an empty label and no keyboard
shortcut.
-
MenuItem(String)
-
Constructs a new MenuItem with the specified label and no
keyboard shortcut.
-
MenuItem(String, MenuShortcut)
- Create a MenuItem with an associated keyboard shortcut.
-
addActionListener(ActionListener)
- Adds the specified action listener to receive action events
from this menu item.
-
addNotify()
- Creates the menu item's peer.
-
deleteShortcut()
- Delete any MenuShortcut associated with this MenuItem.
-
disable()
-
Deprecated.
-
disableEvents(long)
- Disables the events defined by the specified event mask parameter
from being delivered to this menu item.
-
enable()
-
Deprecated.
-
enable(boolean)
-
Deprecated.
-
enableEvents(long)
- Enables the events defined by the specified event mask parameter
to be delivered to this menu item.
-
getActionCommand()
- Returns the command name of the action event fired by this menu item.
-
getLabel()
- Gets the label for this menu item.
-
getShortcut()
- Return the MenuShortcut associated with this MenuItem,
or null if none has been specified.
-
isEnabled()
- Checks whether the menu item is enabled.
-
paramString()
- Returns the String parameter of the menu item.
-
processActionEvent(ActionEvent)
-
Processes action events occurring on this menu item by
dispatching them to any registered ActionListener objects.
-
processEvent(AWTEvent)
- Processes events on this menu item.
-
removeActionListener(ActionListener)
- Removes the specified action listener so it no longer receives
action events from this menu item.
-
setActionCommand(String)
- Sets the command name of the action event fired by this menu item.
-
setEnabled(boolean)
- Sets whether or not this menu item can be chosen.
-
setLabel(String)
- Sets the label to be the specified label.
-
setShortcut(MenuShortcut)
-
Set this MenuItem's MenuShortcut.
MenuItem
method MenuItem() public
- Constructs a new MenuItem with an empty label and no keyboard
shortcut.
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.
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.
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.
getLabel
method getLabel() returns String public
- Gets the label for this menu item.
setLabel
method setLabel(label=String) public protect
- Sets the label to be the specified label.
- Parameters:
- label - the label for this menu item
isEnabled
method isEnabled() returns boolean public
- Checks whether the menu item is enabled.
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
enable
method enable() public protect
- Note: enable() is deprecated.
As of JDK version 1.1,
replaced by setEnabled(boolean).
enable
method enable(b=boolean) public
- Note: enable() is deprecated.
As of JDK version 1.1,
replaced by setEnabled(boolean).
disable
method disable() public protect
- Note: disable() is deprecated.
As of JDK version 1.1,
replaced by setEnabled(boolean).
getShortcut
method getShortcut() returns MenuShortcut public
- Return the MenuShortcut associated with this MenuItem,
or null if none has been specified.
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.
deleteShortcut
method deleteShortcut() public
- Delete any MenuShortcut associated with this MenuItem.
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
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
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.
getActionCommand
method getActionCommand() returns String public
- Returns the command name of the action event fired by this menu item.
addActionListener
method addActionListener(l=ActionListener) public
- Adds the specified action listener to receive action events
from this menu item.
- Parameters:
- l - the action listener
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
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
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
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