java.lang.Object | ||
↳ | java.awt.MenuComponent | |
↳ | java.awt.MenuBar |
The MenuBar
class encapsulates the platform's
concept of a menu bar bound to a frame. In order to associate
the menu bar with a Frame
object, call the
frame's setMenuBar
method.
This is what a menu bar might look like:
A menu bar handles keyboard shortcuts for menu items, passing them
along to its child menus.
(Keyboard shortcuts, which are optional, provide the user with
an alternative to the mouse for invoking a menu item and the
action that is associated with it.)
Each menu item can maintain an instance of MenuShortcut
.
The MenuBar
class defines several methods,
shortcuts()
and
getShortcutMenuItem(MenuShortcut)
that retrieve information about the shortcuts a given
menu bar is managing.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MenuBar.AccessibleAWTMenuBar | Inner class of MenuBar used to provide default support for accessibility. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new menu bar.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds the specified menu to the menu bar.
| |||||||||||
Creates the menu bar's peer.
| |||||||||||
This method is deprecated.
As of JDK version 1.1,
replaced by
getMenuCount() .
| |||||||||||
Deletes the specified menu shortcut.
| |||||||||||
Gets the AccessibleContext associated with this MenuBar.
| |||||||||||
Gets the help menu on the menu bar.
| |||||||||||
Gets the specified menu.
| |||||||||||
Gets the number of menus on the menu bar.
| |||||||||||
Gets the instance of
MenuItem associated
with the specified MenuShortcut object,
or null if none of the menu items being managed
by this menu bar is associated with the specified menu
shortcut. | |||||||||||
Removes the menu located at the specified
index from this menu bar.
| |||||||||||
Removes the specified menu component from this menu bar.
| |||||||||||
Removes the menu bar's peer.
| |||||||||||
Sets the specified menu to be this menu bar's help menu.
| |||||||||||
Gets an enumeration of all menu shortcuts this menu bar
is managing.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.awt.MenuComponent
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.awt.MenuContainer
| |||||||||||
From interface
javax.accessibility.Accessible
|
Creates a new menu bar.
HeadlessException | if GraphicsEnvironment.isHeadless() returns true. |
---|
Adds the specified menu to the menu bar. If the menu has been part of another menu bar, removes it from that menu bar.
m | the menu to be added |
---|
Creates the menu bar's peer. The peer allows us to change the appearance of the menu bar without changing any of the menu bar's functionality.
This method is deprecated.
As of JDK version 1.1,
replaced by getMenuCount()
.
Deletes the specified menu shortcut.
s | the menu shortcut to delete. |
---|
Gets the AccessibleContext associated with this MenuBar. For menu bars, the AccessibleContext takes the form of an AccessibleAWTMenuBar. A new AccessibleAWTMenuBar instance is created if necessary.
Gets the help menu on the menu bar.
Gets the specified menu.
i | the index position of the menu to be returned. |
---|
Gets the number of menus on the menu bar.
Gets the instance of MenuItem
associated
with the specified MenuShortcut
object,
or null
if none of the menu items being managed
by this menu bar is associated with the specified menu
shortcut.
s | the specified menu shortcut. |
---|
Removes the menu located at the specified index from this menu bar.
index | the position of the menu to be removed. |
---|
Removes the specified menu component from this menu bar.
m | the menu component to be removed. |
---|
Removes the menu bar's peer. The peer allows us to change the appearance of the menu bar without changing any of the menu bar's functionality.
Sets the specified menu to be this menu bar's help menu. If this menu bar has an existing help menu, the old help menu is removed from the menu bar, and replaced with the specified menu.
m | the menu to be set as the help menu |
---|
Gets an enumeration of all menu shortcuts this menu bar is managing.