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.
-
Menu()
-
Constructs a new Menu with an empty label.
-
Menu(String)
-
Constructs a new Menu with the specified label.
-
Menu(String, boolean)
-
Constructs a new Menu with the specified label.
-
add(MenuItem)
- Adds the specified item to this menu.
-
add(String)
- Adds an item with with the specified label to this menu.
-
addNotify()
- Creates the menu's peer.
-
addSeparator()
- Adds a separator line, or a hypen, to the menu at the current position.
-
countItems()
-
Deprecated.
-
getItem(int)
- Returns the item located at the specified index of this menu.
-
getItemCount()
-
Returns the number of elements in this menu.
-
insert(MenuItem, int)
- Inserts the MenuItem to this menu at the specified position.
-
insert(String, int)
- Inserts an item with the specified label to this menu
at the specified position.
-
insertSeparator(int)
- Inserts a separator at the specified position
-
isTearOff()
- Returns true if this is a tear-off menu.
-
paramString()
- Returns the String parameter of the menu.
-
remove(int)
- Deletes the item from this menu at the specified index.
-
remove(MenuComponent)
- Deletes the specified item from this menu.
-
removeAll()
- Deletes all items from this menu.
-
removeNotify()
- Removes the menu's peer.
Menu
public Menu()
- Constructs a new Menu with an empty label. This menu can
not be torn off.
Menu
public Menu(String label)
- Constructs a new Menu with the specified label. This menu can
not be torn off.
- Parameters:
- label - the label to be added to this menu
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 then be displayed
in a separate native dialog.
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.
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
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
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.
getItemCount
public int getItemCount()
- Returns the number of elements in this menu.
countItems
public int countItems()
- Note: countItems() is deprecated.
As of JDK version 1.1,
replaced by getItemCount().
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
add
public synchronized MenuItem add(MenuItem mi)
- Adds the specified item to this menu.
- Parameters:
- mi - the item to be added
add
public void add(String label)
- Adds an item with with the specified label to this menu.
- Parameters:
- label - the text on the item
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.
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
addSeparator
public void addSeparator()
- Adds a separator line, or a hypen, to the menu at the current position.
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.
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
remove
public synchronized void remove(MenuComponent item)
- Deletes the specified item from this menu.
- Parameters:
- item - the item to be removed from the menu
removeAll
public synchronized void removeAll()
- Deletes all items from this menu.
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
Submit a bug or feature