| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public class MenuBar extends MenuComponent implements MenuContainer, Accessible
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,
{@link MenuBar#shortcuts} and
{@link MenuBar#getShortcutMenuItem}
that retrieve information about the shortcuts a given
menu bar is managing.
Nested Class Summary | |
---|---|
protected class |
Inner class of MenuBar used to provide default support for accessibility. |
Nested classes/interfaces inherited from class java.awt.MenuComponent |
---|
MenuComponent.AccessibleAWTMenuComponent |
Constructor Summary | |
---|---|
MenuBar() Creates a new menu bar. |
Method Summary | |
---|---|
Menu |
Adds the specified menu to the menu bar. |
void |
Creates the menu bar's peer. |
int |
|
void |
Deletes the specified menu shortcut. |
AccessibleContext |
Gets the AccessibleContext associated with this MenuBar. |
Menu |
Gets the help menu on the menu bar. |
Menu |
getMenu(int i) Gets the specified menu. |
int |
Gets the number of menus on the menu bar. |
MenuItem |
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.
|
void |
remove(int index) Removes the menu located at the specified index from this menu bar. |
void |
Removes the specified menu component from this menu bar. |
void |
Removes the menu bar's peer. |
void |
setHelpMenu(Menu m) Sets the specified menu to be this menu bar's help menu. |
Enumeration |
Gets an enumeration of all menu shortcuts this menu bar is managing. |
Methods inherited from class java.awt.MenuComponent |
---|
dispatchEvent, getAccessibleContext, getFont, getName, getParent, getPeer, getTreeLock, 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 MenuBar() throws HeadlessException
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns true.Method Detail |
---|
public Menu add(Menu m)
m
- the menu to be addedpublic void addNotify()
public int countMenus()
public void deleteShortcut(MenuShortcut s)
s
- the menu shortcut to delete.public AccessibleContext getAccessibleContext()
getAccessibleContext
in class MenuComponent
public Menu getHelpMenu()
public Menu getMenu(int i)
i
- the index position of the menu to be returned.public int getMenuCount()
public MenuItem getShortcutMenuItem(MenuShortcut s)
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.public void remove(int index)
index
- the position of the menu to be removed.public void remove(MenuComponent m)
m
- the menu component to be removed.public void removeNotify()
removeNotify
in class MenuComponent
public void setHelpMenu(Menu m)
m
- the menu to be set as the help menupublic synchronized Enumeration shortcuts()
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |