Class Menu
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Menu

public class netscape.application.Menu
    extends java.lang.Object
{
    /* Constructors
     */
    public Menu();
    public Menu(boolean);

    /* Methods
     */
    public MenuItem addItem(String, String, Target);
    public MenuItem addItem(String, char, String, Target);
    public void addItemAt(MenuItem, int);
    public MenuItem addItemWithSubmenu(String);
    public Menu createMenuAsSubmenu();
    public boolean handleCommandKeyEvent(KeyEvent);
    public int indexOfItem(MenuItem);
    public MenuItem itemAt(int);
    public int itemCount();
    public MenuItem prototypeItem();
    public void removeItem(MenuItem);
    public void removeItemAt(int);
    public void setPrototypeItem(MenuItem);
}
Object subclass managing a collection of MenuItems that appear along the top edge of an ExternalWindow. There are two Menu types: top-level main menus and submenus (a menu invoked by a MenuItem). Top-level menus have an associated java.awt.MenuBar, while submenus have an associated java.awt.Menu. You generally create a new Menu and add MenuItems to it, configuring them with submenus as appropriate. The following code creates a Menu with a single MenuItem containing a single-item submenu:
    menu = new Menu(true);
    menuItem = menu.addItemWithSubmenu("Menu One");
    menuItem.submenu().addItem("Item One", command, target);
    window.setMenu(menu);
Note: The Menu class does not support the insertion of a submenu-less MenuItem into a top-level Menu.
See Also:
MenuItem

Constructors

Menu

  public Menu()
Constructs a Menu.

Menu

  public Menu(boolean topLevel)
Constructs a Menu. If topLevel is true, makes the new Menu a top-level menu.

Methods

setPrototypeItem

  public void setPrototypeItem(MenuItem prototype)
Sets the prototype MenuItem for this Menu. Whenever the Menu needs a new MenuItem, it clones the prototype MenuItem.

prototypeItem

  public MenuItem prototypeItem()
Returns the Menu's prototype MenuItem.
See Also:
setPrototypeItem

createMenuAsSubmenu

  public Menu createMenuAsSubmenu()
Creates a new Menu for use as a MenuItem's submenu. Called by addItemWithSubmenu(). Subclassers should override this method to return a subclass instance.

addItemWithSubmenu

  public MenuItem addItemWithSubmenu(String title)
Adds a new MenuItem, containing a submenu, to the end of this Menu, with title title.

addItem

  public MenuItem addItem(String title,
                          String command,
                          Target target)
Adds a new MenuItem to the end of this Menu, with title title, command command and Target target.

addItem

  public MenuItem addItem(String title,
                          char key,
                          String command,
                          Target target)
Adds a new MenuItem to the end of this Menu, with title title, command key equivalent key, command command and Target target.

indexOfItem

  public int indexOfItem(MenuItem item)
Returns the index of the specified MenuItem.

itemCount

  public int itemCount()
Returns the number of MenuItems this Menu contains.

itemAt

  public MenuItem itemAt(int index)
Returns the MenuItem at index.

addItemAt

  public void addItemAt(MenuItem menuItem,
                        int index)
Adds the MenuItem menuItem at index.

removeItem

  public void removeItem(MenuItem menuItem)
Removes menuItem from the Menu.

removeItemAt

  public void removeItemAt(int index)
Removes the MenuItem at index.

handleCommandKeyEvent

  public boolean handleCommandKeyEvent(KeyEvent event)
Examines all MenuItems for a command key equivalent. If the Menu finds a match, this method performs the corresponding command and returns true.

All Packages  Class Hierarchy  This Package  Previous  Next  Index