home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Java in a Nutshell

Previous Chapter 18
The java.awt Package

18.44 java.awt.MenuItem (JDK 1.0)

This class encapsulates a menu item with a specified textual label. A MenuItem can be added to a menu pane with the Menu.add() method. The disable() method makes an item non-selectable; you might use it to "gray-out" a menu item when the command it represents is not valid in the current context. The enable() method makes an item selectable again. In Java 1.1, use setActionCommand() to specify an identifying string that is included in ActionEvent events generated by the menu item.

public class MenuItem extends MenuComponent {
    // Public Constructors
        1.1  public MenuItem();
            public MenuItem(String label);
        1.1  public MenuItem(String label, MenuShortcut s);
    // Public Instance Methods
        1.1  public synchronized void addActionListener(ActionListener l);
            public void addNotify();
        1.1  public void deleteShortcut();
        #   public synchronized void disable();
        #   public synchronized void enable();
        #   public void enable(boolean b);
        1.1  public String getActionCommand();
            public String getLabel();
        1.1  public MenuShortcut getShortcut();
            public boolean isEnabled();
            public String paramString();  // Overrides MenuComponent
        1.1  public synchronized void removeActionListener(ActionListener l);
        1.1  public void setActionCommand(String command);
        1.1  public synchronized void setEnabled(boolean b);
            public synchronized void setLabel(String label);
        1.1  public void setShortcut(MenuShortcut s);
    // Protected Instance Methods
        1.1  protected final void disableEvents(long eventsToDisable);
        1.1  protected final void enableEvents(long eventsToEnable);
        1.1  protected void processActionEvent(ActionEvent e);
        1.1  protected void processEvent(AWTEvent e);  // Overrides MenuComponent



Extended By:

CheckboxMenuItem, Menu

Passed To:

Menu.add(), Menu.insert(), MenuPeer.addItem(), Toolkit.createMenuItem()

Returned By:

Menu.add(), Menu.getItem(), MenuBar.getShortcutMenuItem()

Previous Home Next
java.awt.MenuContainer (JDK 1.0) Book Index java.awt.MenuShortcut (JDK 1.1)

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java