Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |
java.lang.Object | +----java.awt.MenuComponent | +----java.awt.MenuItem | +----java.awt.Menu
Menu
object is a pull-down menu component
that is deployed from a menu bar.
A menu can optionally be a tear-off menu. A tear-off menu can be opened and dragged away from its parent menu bar or menu. It remains on the screen after the mouse button has been released. The mechanism for tearing off a menu is platform dependent, since the look and feel of the tear-off menu is determined by its peer. On platforms that do not support tear-off menus, the tear-off property is ignored.
Each item in a menu must belong to the MenuItem
class. It can be an instance of MenuItem
, a submenu
(an instance of Menu
), or a check box (an instance of
CheckboxMenuItem
).
Constructor Summary | |
Menu()
|
|
Menu(String label)
|
|
Menu(String label,
boolean tearOff)
|
Method Summary | |
MenuItem | add(MenuItem mi)
|
void | add(String label)
|
void | addNotify()
|
void | addSeparator()
|
int | countItems()
|
MenuItem | getItem(int index)
|
int | getItemCount()
|
void | insert(MenuItem menuitem,
int index)
|
void | insert(String label,
int index)
|
void | insertSeparator(int index)
|
boolean | isTearOff()
|
String | paramString()
|
void | remove(int index)
|
void | remove(MenuComponent item)
|
void | removeAll()
|
void | removeNotify()
|
Methods inherited from class java.awt.MenuItem |
addActionListener, addNotify, deleteShortcut, disable, disableEvents, enable, enable, enableEvents, getActionCommand, getLabel, getShortcut, isEnabled, paramString, processActionEvent, processEvent, removeActionListener, setActionCommand, setEnabled, setLabel, setShortcut |
Methods inherited from class java.awt.MenuComponent |
dispatchEvent, getFont, getName, getParent, getPeer, paramString, postEvent, processEvent, removeNotify, setFont, setName, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Menu()
public Menu(String label)
label
- the menu's label in the menu bar, or in
another menu of which this menu is a submenu.
public Menu(String label, boolean tearOff)
tearOff
is true
,
the menu can be torn off.
Tear-off functionality may not be supported by all implementations of AWT. If a particular implementation doesn't support tear-off menus, this value is silently ignored.
label
- the menu's label in the menu bar, or in
another menu of which this menu is a submenu.
tearOff
- if true
, the menu
is a tear-off menu.
Method Detail |
public void addNotify()
public void removeNotify()
public boolean isTearOff()
Tear-off functionality may not be supported by all implementations of AWT. If a particular implementation doesn't support tear-off menus, this value is silently ignored.
true
if this is a tear-off menu;
false
otherwise.public int getItemCount()
public int countItems()
getItemCount()
.
public MenuItem getItem(int index)
index
- the position of the item to be returned.
public MenuItem add(MenuItem mi)
mi
- the menu item to be added.
public void add(String label)
label
- the text on the item.
public void insert(MenuItem menuitem, int index)
menuitem
- the menu item to be inserted.
index
- the position at which the menu
item should be inserted.
index
is less than zero.public void insert(String label, int index)
label
- the text on the item.
index
- the position at which the menu item
should be inserted.
public void addSeparator()
public void insertSeparator(int index)
index
- the position at which the
menu separator should be inserted.
index
is less than 0.public void remove(int index)
index
- the position of the item to be removed.
public void remove(MenuComponent item)
item
- the item to be removed from the menu
public void removeAll()
public String paramString()
Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |