Class java.awt.Menu
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.awt.Menu

java.lang.Object
   |
   +----java.awt.MenuComponent
           |
           +----java.awt.MenuItem
                   |
                   +----java.awt.Menu

public class Menu
extends MenuItem
implements MenuContainer
A Menu that is a component of a menu bar.

Constructor Index

 o Menu(String)
Constructs a new Menu with the specified label.
 o Menu(String, boolean)
Constructs a new Menu with the specified label.

Method Index

 o add(MenuItem)
Adds the specified item to this menu.
 o add(String)
Add an item with with the specified label to this menu.
 o addNotify()
Creates the menu's peer.
 o addSeparator()
Adds a separator line, or a hypen, to the menu at the current position.
 o countItems()
Returns the number of elements in this menu.
 o getItem(int)
Returns the item located at the specified index of this menu.
 o isTearOff()
Returns true if this is a tear-off menu.
 o remove(int)
Deletes the item at the specified index from this menu.
 o remove(MenuComponent)
Deletes the specified item from this menu.
 o removeNotify()
Removes the menu's peer.

Constructors

 o Menu
  public Menu(String label)
Constructs a new Menu with the specified label. This menu will not be able to be torn off. Torn off means that the menu will still appear on screen after the the mouse button has been released.
Parameters:
label - the label to be added to this menu
 o Menu
  public Menu(String label,
              boolean tearOff)
Constructs a new Menu with the specified label. The menu will be able to be torn off if tearOff is true. Torn off means that the menu will still appear on screen after the the mouse button has been released.
Parameters:
label - the label to be added to this menu
tearOff - the boolean indicating whether or not the menu will be able to be torn off.

Methods

 o addNotify
  public synchronized void addNotify()
Creates the menu's peer. The peer allows us to modify the appearance of the menu without changing its functionality.
Overrides:
addNotify in class MenuItem
 o removeNotify
  public synchronized void removeNotify()
Removes the menu's peer. The peer allows us to modify the appearance of the menu without changing its functionality.
Overrides:
removeNotify in class MenuComponent
 o isTearOff
  public boolean isTearOff()
Returns true if this is a tear-off menu. Torn off means that the menu will still appear on screen after the the mouse button has been released.
 o countItems
  public int countItems()
Returns the number of elements in this menu.
 o getItem
  public MenuItem getItem(int index)
Returns the item located at the specified index of this menu.
Parameters:
index - the position of the item to be returned
 o add
  public synchronized MenuItem add(MenuItem mi)
Adds the specified item to this menu.
Parameters:
mi - the item to be added
 o add
  public void add(String label)
Add an item with with the specified label to this menu.
Parameters:
label - the text on the item
 o addSeparator
  public void addSeparator()
Adds a separator line, or a hypen, to the menu at the current position.
 o remove
  public synchronized void remove(int index)
Deletes the item at the specified index from this menu.
Parameters:
index - the position of the item to be removed
 o remove
  public synchronized void remove(MenuComponent item)
Deletes the specified item from this menu.
Parameters:
item - the item to be removed from the menu

All Packages  Class Hierarchy  This Package  Previous  Next  Index