com.droplets.api
Class Menu

java.lang.Object
  |
  +--com.droplets.api.MenuComponent
        |
        +--com.droplets.api.MenuItem
              |
              +--com.droplets.api.Menu
All Implemented Interfaces:
MenuContainer

public class Menu
extends MenuItem
implements MenuContainer

A pulldown menu that contains menu components, which may be MenuItems, CheckboxMenuItems, and other Menus (sometimes called submenus). You add menu items to a menu directly by calling add(com.droplets.api.MenuItem). The menu items appear in the order that you add them, top to bottom.

Items can only be added to a Menu during the Window.addAllComponents() method. Any attempt to add items to a Menu outside this method is ignored.

Register for menu events for a Menu by calling MenuComponent.addActionListener(com.droplets.api.event.ActionListener). The listener receives ActionEvents for all the items in the menu, including any items contained in submenus.


Constructor Summary
Menu()
          Constructs a new Menu.
Menu(java.lang.String label)
          Constructs a menu with the specified label.
 
Method Summary
 MenuItem add(MenuItem mi)
          Adds the specified menu item to the end of this menu.
 MenuItem add(java.lang.String label)
          Adds a menu item with the specified label to the menu and returns the created menu item.
 MenuItem add(java.lang.String label, java.lang.String actionCommand)
          Adds a menu item with the specified label and action command to the menu and returns the created menu item.
 void addSeparator()
          Adds a separator line to the end of the menu.
 
Methods inherited from class com.droplets.api.MenuItem
getActionCommand, getLabel, isEnabled, setActionCommand, setEnabled, setLabel
 
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

Menu

public Menu()
Constructs a new Menu.

Menu

public Menu(java.lang.String label)
Constructs a menu with the specified label.
Parameters:
label - the string displayed on the menu bar for this menu.
Method Detail

add

public MenuItem add(MenuItem mi)
Adds the specified menu item to the end of this menu. It is an error for a menu item to be added to more than one menu.
Parameters:
mi - menu item to be added.
Returns:
menu item that was added.

add

public MenuItem add(java.lang.String label)
Adds a menu item with the specified label to the menu and returns the created menu item. Specify "-" for the label to add a menu separator.

Note that this method creates a menu item that has no action command.

Parameters:
label - the label for the new menu item.
Returns:
the menu item that was added.

add

public MenuItem add(java.lang.String label,
                    java.lang.String actionCommand)
Adds a menu item with the specified label and action command to the menu and returns the created menu item. Specify "-" for the label to add a menu separator.
Parameters:
label - the label for the new menu item.
actionCommand - the action command for the new menu item.
Returns:
the menu item that was added.

addSeparator

public void addSeparator()
Adds a separator line to the end of the menu.


Copyright © Droplets, 2001. All Rights Reserved.