java.lang.Object
java.awt.MenuComponent
java.awt.MenuBar
protected class
MenuBar.AccessibleAWTMenuBar
MenuBar()
MenuBar
.
void
addNotify()
int
countMenus()
getMenuCount()
. void
deleteShortcut(MenuShortcut shortcut)
AccessibleContext
getAccessibleContext()
MenuBar
.
Menu
getHelpMenu()
int
getMenuCount()
MenuItem
getShortcutMenuItem(MenuShortcut shortcut)
null
if no such item exists.
void
remove(int index)
void
remove(MenuComponent menu)
void
removeNotify()
void
setHelpMenu(Menu menu)
Enumeration
shortcuts()
public MenuBar()
Initializes a new instance ofMenuBar
.
- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() is true
public Menu add(Menu menu)
Add a menu to this MenuBar. If the menu has already has a parent, it is first removed from its old parent before being added.
- Parameters:
menu
- the menu to add
- Returns:
- the menu that was added
public int countMenus()
Deprecated. This method is deprecated in favor of
getMenuCount()
.Returns the number of elements in this menu bar.
- Returns:
- the number of elements in the menu bar
public void deleteShortcut(MenuShortcut shortcut)
Deletes the specified menu shortcut.
- Parameters:
shortcut
- the shortcut to delete
public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with thisMenuBar
. The context is created, if necessary.
- Specified by:
- getAccessibleContext in interface Accessible
- Overrides:
- getAccessibleContext in interface MenuComponent
- Returns:
- the associated context
public Menu getHelpMenu()
Returns the help menu for this menu bar. This may benull
.
- Returns:
- the help menu for this menu bar
public Menu getMenu(int index)
Returns the menu at the specified index.
- Parameters:
index
- the index of the menu
- Returns:
- the requested menu
- Throws:
ArrayIndexOutOfBoundsException
- if the index is not valid
public int getMenuCount()
Returns the number of elements in this menu bar.
- Returns:
- the number of elements in the menu bar
public MenuItem getShortcutMenuItem(MenuShortcut shortcut)
Returns the menu item for the specified shortcut, ornull
if no such item exists.
- Parameters:
shortcut
- the shortcut to return the menu item for
- Returns:
- the menu item for the specified shortcut
public void remove(int index)
Removes the menu at the specified index.
- Parameters:
index
- the index of the menu to remove from the menu bar
public void remove(MenuComponent menu)
Removes the specified menu from the menu bar.
- Specified by:
- remove in interface MenuContainer
- Parameters:
menu
- the menu to remove from the menu bar
public void removeNotify()
Destroys this object's native peer.
- Overrides:
- removeNotify in interface MenuComponent
public void setHelpMenu(Menu menu)
Sets the help menu for this menu bar.
- Parameters:
menu
- the new help menu for this menu bar
public Enumerationshortcuts()
Returns a list of all shortcuts for the menus in this menu bar.
- Returns:
- a list of all shortcuts for the menus in this menu bar