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 }
Object->MenuComponent(Serializable)->MenuItem
CheckboxMenuItem, Menu
Menu.add(), Menu.insert(), MenuPeer.addItem(), Toolkit.createMenuItem()
Menu.add(), Menu.getItem(), MenuBar.getShortcutMenuItem()
This HTML Help has been published using the chm2web software. |