java.lang.Object java.awt.MenuComponent java.awt.MenuItem java.awt.Menu
public class Menu
A 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
).
MenuItem
, CheckboxMenuItem
, Serialized Form
protected class
Menu.AccessibleAWTMenu
Menu()
Menu(String label)
Menu(String label, boolean tearOff)
MenuItem
add(MenuItem mi)
void
add(String label)
void
addNotify()
void
addSeparator()
int
countItems()
getItemCount()
. AccessibleContext
getAccessibleContext()
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()
Menu
. void
remove(int index)
void
remove(MenuComponent item)
void
removeAll()
void
removeNotify()
addActionListener, deleteShortcut, disable, disableEvents, enable, enable, enableEvents, getActionCommand, getActionListeners, getLabel, getListeners, getShortcut, isEnabled, processActionEvent, processEvent, removeActionListener, setActionCommand, setEnabled, setLabel, setShortcut
Menu
public Menu() throws HeadlessException
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true.
GraphicsEnvironment.isHeadless()
public Menu(String label) throws HeadlessException
label
- the menu's label in the menu bar, or in another menu of which this menu is a submenu.
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true.
GraphicsEnvironment.isHeadless()
public Menu(String label, boolean tearOff) throws HeadlessException
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.
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true.
GraphicsEnvironment.isHeadless()
public void addNotify()
addNotify
in class MenuItem
public void removeNotify()
removeNotify
in class MenuComponent
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()
@Deprecated 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
insert(java.lang.String, int)
, insert(java.awt.MenuItem, int)
public void add(String label)
label
- the text on the item
insert(java.lang.String, int)
, insert(java.awt.MenuItem, int)
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.
IllegalArgumentException
- if the value of index
is less than zero
add(java.lang.String)
, add(java.awt.MenuItem)
public void insert(String label, int index)
insert(menuItem, index)
.
label
- the text on the item
index
- the position at which the menu item should be inserted
IllegalArgumentException
- if the value of index
is less than zero
add(java.lang.String)
, add(java.awt.MenuItem)
public void addSeparator()
insertSeparator(int)
public void insertSeparator(int index)
index
- the position at which the menu separator should be inserted.
IllegalArgumentException
- if the value of index
is less than 0.
addSeparator()
public void remove(int index)
index
- the position of the item to be removed.
public void remove(MenuComponent item)
remove
in interface MenuContainer
item
- the item to be removed from the menu. If item
is null
or is not in this menu, this method does nothing.
public void removeAll()
public String paramString()
Menu
. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null
.
paramString
in class MenuItem
public AccessibleContext getAccessibleContext()
getAccessibleContext
in interface Accessible
getAccessibleContext
in class MenuItem
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4