Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class MenuItem

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

All Implemented Interfaces:

Serializable, Serializable


public class MenuItem

extends MenuComponent

implements Serializable

This class represents an item in a menu.

Author:

Constructor Summary

MenuItem()

Initializes a new instance of MenuItem with no label and no shortcut.
MenuItem(java.lang.String label)

Initializes a new instance of MenuItem with the specified label and no shortcut.
MenuItem(java.lang.String label, java.awt.MenuShortcut shortcut)

Initializes a new instance of MenuItem with the specified label and shortcut.

Method Summary

synchronized voidaddActionListener(java.awt.event.ActionListener listener)

Adds the specified listener to the list of registered action listeners for this component.
voidaddNotify()

Creates the native peer for this object.
voiddeleteShortcut()

Deletes the shortcut for this menu item if one exists.
voiddisable()

Disables this menu item.
voiddisableEvents(long events)

Disables the specified events.
voidenable(boolean enabled)

Sets the enabled status of this menu item.
voidenable()

Enables this menu item.
voidenableEvents(long events)

Enables the specified events.
java.lang.StringgetActionCommand()

Returns the name of the action command in the action events generated by this menu item.
synchronized java.awt.event.ActionListener[]getActionListeners()

java.lang.StringgetLabel()

Returns the label for this menu item, which may be null.
java.util.EventListener[]getListeners(java.lang.Class listenerType)

Returns all registered EventListers of the given listenerType.
java.awt.MenuShortcutgetShortcut()

Returns the shortcut for this menu item, which may be null.
booleanisEnabled()

Tests whether or not this menu item is enabled.
java.lang.StringparamString()

Returns a debugging string for this object.
voidprocessActionEvent(java.awt.event.ActionEvent event)

Processes the specified event by dispatching it to any registered listeners.
voidprocessEvent(java.awt.AWTEvent event)

Processes the specified event by calling processActionEvent() if it is an instance of ActionEvent.
synchronized voidremoveActionListener(java.awt.event.ActionListener l)

voidsetActionCommand(java.lang.String actionCommand)

Sets the name of the action command in the action events generated by this menu item.
synchronized voidsetEnabled(boolean enabled)

Sets the enabled status of this menu item.
synchronized voidsetLabel(java.lang.String label)

This method sets the label for this menu to the specified value.
voidsetShortcut(java.awt.MenuShortcut shortcut)

Sets the shortcut for this menu item to the specified value.

Constructor Details

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:


Method Details

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:


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:


isEnabled

public boolean isEnabled()

Tests whether or not this menu item is enabled.

Returns:


paramString

public String paramString()

Returns a debugging string for this object.

Returns:


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: