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
public MenuItem()
- Constructs a new MenuItem with an empty label and no keyboard
shortcut.
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.
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.
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.
getLabel
public String getLabel()
- Gets the label for this menu item.
setLabel
public synchronized void setLabel(String label)
- Sets the label to be the specified label.
- Parameters:
- label - the label for this menu item
isEnabled
public boolean isEnabled()
- Checks whether the menu item is enabled.
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
enable
public synchronized void enable()
- Note: enable() is deprecated.
As of JDK version 1.1,
replaced by setEnabled(boolean).
enable
public void enable(boolean b)
- Note: enable() is deprecated.
As of JDK version 1.1,
replaced by setEnabled(boolean).
disable
public synchronized void disable()
- Note: disable() is deprecated.
As of JDK version 1.1,
replaced by setEnabled(boolean).
getShortcut
public MenuShortcut getShortcut()
- Return the MenuShortcut associated with this MenuItem,
or null if none has been specified.
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.
deleteShortcut
public void deleteShortcut()
- Delete any MenuShortcut associated with this MenuItem.
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
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
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.
getActionCommand
public String getActionCommand()
- Returns the command name of the action event fired by this menu item.
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
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
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
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
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
Submit a bug or feature