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()
Constructs a new Menu with an empty label.
 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)
Adds 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()
Deprecated.
 o getItem(int)
Returns the item located at the specified index of this menu.
 o getItemCount()
Returns the number of elements in this menu.
 o insert(MenuItem, int)
Inserts the MenuItem to this menu at the specified position.
 o insert(String, int)
Inserts an item with the specified label to this menu at the specified position.
 o insertSeparator(int)
Inserts a separator at the specified position
 o isTearOff()
Returns true if this is a tear-off menu.
 o paramString()
Returns the String parameter of the menu.
 o remove(int)
Deletes the item from this menu at the specified index.
 o remove(MenuComponent)
Deletes the specified item from this menu.
 o removeAll()
Deletes all items from this menu.
 o removeNotify()
Removes the menu's peer.

Constructors

 o Menu
 public Menu()
Constructs a new Menu with an empty label. This menu can not be torn off - the menu will still appear on screen after the the mouse button has been released.

 o Menu
 public Menu(String label)
Constructs a new Menu with the specified label. This menu can not be torn off - 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. If tearOff is true, the menu can be torn off - the menu will still appear on screen after the the mouse button has been released. NOTE: tear-off functionality may not be supported by all AWT implementations. If a particular implementation doesn't support tear-offs, this value will be silently ignored.

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 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 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. NOTE: tear-off functionality may not be supported by all AWT implementations. If a particular implementation doesn't support tear-offs, this value will be silently ignored.

 o getItemCount
 public int getItemCount()
Returns the number of elements in this menu.

 o countItems
 public int countItems()
Note: countItems() is deprecated. As of JDK version 1.1, replaced by getItemCount().

 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)
Adds an item with with the specified label to this menu.

Parameters:
label - the text on the item
 o insert
 public synchronized void insert(MenuItem menuitem,
                                 int index)
Inserts the MenuItem to this menu at the specified position.

Parameters:
menuitem - the menu item to be inserted
index - the position at which the menu item should be inserted
Throws: IllegalArgumentException
if index is less than 0.
 o insert
 public void insert(String label,
                    int index)
Inserts an item with the specified label to this menu at the specified position.

Parameters:
label - the text on the item
index - the position at which the menu item should be inserted
 o addSeparator
 public void addSeparator()
Adds a separator line, or a hypen, to the menu at the current position.

 o insertSeparator
 public void insertSeparator(int index)
Inserts a separator at the specified position

Parameters:
index - the position at which the menu separator should be inserted
Throws: IllegalArgumentException
if index is less than 0.
 o remove
 public synchronized void remove(int index)
Deletes the item from this menu at the specified index.

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
 o removeAll
 public synchronized void removeAll()
Deletes all items from this menu.

 o paramString
 public String paramString()
Returns the String parameter of the menu.

Overrides:
paramString in class MenuItem

All Packages  Class Hierarchy  This Package  Previous  Next  Index