public class MenuBar extends MenuComponent implements MenuContainer, Serializable, Accessible
| Modifier and Type | Class and Description |
|---|---|
protected class |
MenuBar.AccessibleAWTMenuBar
This class provides accessibility support for AWT menu bars.
|
MenuComponent.AccessibleAWTMenuComponent| Constructor and Description |
|---|
MenuBar()
Initializes a new instance of
MenuBar. |
| Modifier and Type | Method and Description |
|---|---|
Menu |
add(Menu menu)
Add a menu to this MenuBar.
|
void |
addNotify()
Creates this object's native peer.
|
int |
countMenus()
Deprecated.
This method is deprecated in favor of
getMenuCount(). |
void |
deleteShortcut(MenuShortcut shortcut)
Deletes the specified menu shortcut.
|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this
MenuBar. |
Menu |
getHelpMenu()
Returns the help menu for this menu bar.
|
Menu |
getMenu(int index)
Returns the menu at the specified index.
|
int |
getMenuCount()
Returns the number of elements in this menu bar.
|
MenuItem |
getShortcutMenuItem(MenuShortcut shortcut)
Returns the menu item for the specified shortcut, or
null
if no such item exists. |
void |
remove(int index)
Removes the menu at the specified index.
|
void |
remove(MenuComponent menu)
Removes the specified menu from the menu bar.
|
void |
removeNotify()
Destroys this object's native peer.
|
void |
setHelpMenu(Menu menu)
Sets the help menu for this menu bar.
|
Enumeration<MenuShortcut> |
shortcuts()
Returns a list of all shortcuts for the menus in this menu bar.
|
dispatchEvent, getFont, getName, getParent, getPeer, getTreeLock, paramString, postEvent, processEvent, setFont, setName, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetFont, postEventpublic MenuBar()
MenuBar.HeadlessException - if GraphicsEnvironment.isHeadless() is truepublic Menu getHelpMenu()
null.public void setHelpMenu(Menu menu)
menu - the new help menu for this menu barpublic Menu add(Menu menu)
menu - the menu to addpublic void remove(int index)
index - the index of the menu to remove from the menu barpublic void remove(MenuComponent menu)
remove in interface MenuContainermenu - the menu to remove from the menu barpublic int getMenuCount()
public int countMenus()
getMenuCount().public Menu getMenu(int index)
index - the index of the menuArrayIndexOutOfBoundsException - if the index is not validpublic void addNotify()
public void removeNotify()
removeNotify in class MenuComponentpublic Enumeration<MenuShortcut> shortcuts()
public MenuItem getShortcutMenuItem(MenuShortcut shortcut)
null
if no such item exists.shortcut - the shortcut to return the menu item forpublic void deleteShortcut(MenuShortcut shortcut)
shortcut - the shortcut to deletepublic AccessibleContext getAccessibleContext()
MenuBar.
The context is created, if necessary.getAccessibleContext in interface AccessiblegetAccessibleContext in class MenuComponent