com.droplets.api
Class MenuItem

java.lang.Object
  |
  +--com.droplets.api.MenuComponent
        |
        +--com.droplets.api.MenuItem
Direct Known Subclasses:
CheckboxMenuItem, EditCopyMenuItem, EditCutMenuItem, EditPasteMenuItem, Menu

public class MenuItem
extends MenuComponent

Represents items that can be placed in a Menu. MenuItems have a label (the text displayed on the menu), and an action command (an additional string passed to listeners when events are fired by a menu item). Menu items can be enabled or disabled using setEnabled(boolean).

Register for menu events for a MenuItem by calling MenuComponent.addActionListener(com.droplets.api.event.ActionListener). The listener receives ActionEvents when the menu item is selected.

Menus and CheckboxMenuItems are special kinds of MenuItems.


Constructor Summary
MenuItem()
          Constructs a MenuItem with neither a label nor an action command.
MenuItem(java.lang.String label)
          Constructs a menu item with the specified label, but no action command.
MenuItem(java.lang.String label, java.lang.String actionCommand)
          Constructs a menu item with the specified label and action command.
 
Method Summary
 java.lang.String getActionCommand()
          Returns the action command string for this menu item.
 java.lang.String getLabel()
          Returns the label of this menu item.
 boolean isEnabled()
          Returns true if this menu item is currently enabled (i.e.
 void setActionCommand(java.lang.String command)
          Sets the action command string for this menu item.
 void setEnabled(boolean isEnabled)
          If isEnabled() is true, this menu item is made available for selection, otherwise it is unavailable.
 void setLabel(java.lang.String label)
          Sets the label of this menu item.
 
Methods inherited from class com.droplets.api.MenuComponent
addActionListener, getParent, removeActionListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuItem

public MenuItem()
Constructs a MenuItem with neither a label nor an action command.

MenuItem

public MenuItem(java.lang.String label)
Constructs a menu item with the specified label, but no action command.
Parameters:
label - the label for this menu item.

MenuItem

public MenuItem(java.lang.String label,
                java.lang.String actionCommand)
Constructs a menu item with the specified label and action command.
Parameters:
label - the label for this menu item.
actionCommand - the action command for this menu item.
Method Detail

getActionCommand

public java.lang.String getActionCommand()
Returns the action command string for this menu item. The action command is the string that is placed inside the ActionEvent object passed to the action listener after the menu item is selected.
Returns:
java.lang.String

getLabel

public java.lang.String getLabel()
Returns the label of this menu item. The label is the string that is displayed on the menu item.
Returns:
java.lang.String

isEnabled

public boolean isEnabled()
Returns true if this menu item is currently enabled (i.e. available for selection), false if it is disabled.
Returns:
boolean

setActionCommand

public void setActionCommand(java.lang.String command)
Sets the action command string for this menu item. The action command is the string that is placed inside the ActionEvent object passed to the action listener after the menu item is selected.
Parameters:
command - java.lang.String

setEnabled

public void setEnabled(boolean isEnabled)
If isEnabled() is true, this menu item is made available for selection, otherwise it is unavailable. Menu items are enabled by default.
Parameters:
isEnabled - boolean

setLabel

public void setLabel(java.lang.String label)
Sets the label of this menu item. The label is the string that is displayed on the menu item.
Parameters:
label - java.lang.String


Copyright © Droplets, 2001. All Rights Reserved.