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
    method Menu() public 
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
    method Menu(label=String) public 
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
    method Menu(label=String, -
                tearOff=boolean) public 
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
    method addNotify()  public     
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
    method removeNotify()  public     
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
    method isTearOff() returns boolean public     
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
    method getItemCount() returns int public     
Returns the number of elements in this menu.

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

 o getItem
    method getItem(index=int) returns MenuItem public     
Returns the item located at the specified index of this menu.

Parameters:
index - the position of the item to be returned
 o add
    method add(mi=MenuItem) returns MenuItem public    protect 
Adds the specified item to this menu.

Parameters:
mi - the item to be added
 o add
    method add(label=String)  public     
Adds an item with with the specified label to this menu.

Parameters:
label - the text on the item
 o insert
    method insert(menuitem=MenuItem, -
                  index=int)  public    protect 
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
    method insert(label=String, -
                  index=int)  public     
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
    method addSeparator()  public     
Adds a separator line, or a hypen, to the menu at the current position.

 o insertSeparator
    method insertSeparator(index=int)  public     
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
    method remove(index=int)  public    protect 
Deletes the item from this menu at the specified index.

Parameters:
index - the position of the item to be removed
 o remove
    method remove(item=MenuComponent)  public    protect 
Deletes the specified item from this menu.

Parameters:
item - the item to be removed from the menu
 o removeAll
    method removeAll()  public    protect 
Deletes all items from this menu.

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

Overrides:
paramString in class MenuItem

All Packages  Class Hierarchy  This Package  Previous  Next  Index