Class java.awt.MenuBar
All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.MenuBar
Object
|
+----MenuComponent
|
+----java.awt.MenuBar
- public class MenuBar
- extends MenuComponent
- implements MenuContainer
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
that retrieve information about the shortcuts a given
menu bar is managing.
- Version:
- 1.38, 08/21/98
- Author:
- Sami Shaio
- Since:
- JDK1.0
- See Also:
- Frame, setMenuBar(java.awt.MenuBar), Menu, MenuItem, MenuShortcut
-
java.awt.MenuBar()
- Creates a new menu bar.
-
add(Menu)
- Adds the specified menu to the menu bar.
-
addNotify()
- Creates the menu bar's peer.
-
countMenus()
-
-
deleteShortcut(MenuShortcut)
- Deletes the specified menu shortcut.
-
getHelpMenu()
- Gets the help menu on the menu bar.
-
getMenu(int)
- Gets the specified menu.
-
getMenuCount()
- Gets the number of menus on the menu bar.
-
getShortcutMenuItem(MenuShortcut)
- Gets the instance of
MenuItem
associated
with the specified MenuShortcut
object,
or null
if none has been specified.
-
remove(int)
- Removes the menu located at the specified
index from this menu bar.
-
remove(MenuComponent)
- Removes the specified menu component from this menu bar.
-
removeNotify()
- Removes the menu bar's peer.
-
setHelpMenu(Menu)
- Sets the help menu on this menu bar to be the specified menu.
-
shortcuts()
-
Gets an enumeration of all menu shortcuts this menu bar
is managing.
MenuBar
public MenuBar()
- Creates a new menu bar.
- Since:
- JDK1.0
add
public java.awt.Menu add(Menu m)
- Adds the specified menu to the menu bar.
- Parameters:
- m - the menu to be added.
- Returns:
- the menu added.
- Since:
- JDK1.0
- See Also:
- remove(int), remove(java.awt.MenuComponent)
addNotify
public void addNotify()
- 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.
countMenus
public int countMenus()
- Note: countMenus() is deprecated.
As of JDK version 1.1,
replaced by
getMenuCount()
.
-
deleteShortcut
public void deleteShortcut(MenuShortcut s)
- Deletes the specified menu shortcut.
- Parameters:
- s - the menu shortcut to delete.
- Since:
- JDK1.1
getHelpMenu
public java.awt.Menu getHelpMenu()
- Gets the help menu on the menu bar.
- Returns:
- the help menu on this menu bar.
- Since:
- JDK1.0
getMenu
public java.awt.Menu getMenu(int i)
- Gets the specified menu.
- Parameters:
- i - the index position of the menu to be returned.
- Returns:
- the menu at the specified index of this menu bar.
- Since:
- JDK1.0
getMenuCount
public int getMenuCount()
- Gets the number of menus on the menu bar.
- Returns:
- the number of menus on the menu bar.
- Since:
- JDK1.1
getShortcutMenuItem
public java.awt.MenuItem getShortcutMenuItem(MenuShortcut s)
- Gets the instance of
MenuItem
associated
with the specified MenuShortcut
object,
or null
if none has been specified.
- Parameters:
- s - the specified menu shortcut.
- Since:
- JDK1.1
- See Also:
- MenuItem, MenuShortcut
remove
public void remove(int index)
- Removes the menu located at the specified
index from this menu bar.
- Parameters:
- index - the position of the menu to be removed.
- Since:
- JDK1.0
- See Also:
- add(java.awt.Menu)
remove
public void remove(MenuComponent m)
- Removes the specified menu component from this menu bar.
- Parameters:
- m - the menu component to be removed.
- Since:
- JDK1.0
- See Also:
- add(java.awt.Menu)
removeNotify
public void removeNotify()
- 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.
- Overrides:
- removeNotify in class MenuComponent
setHelpMenu
public void setHelpMenu(Menu m)
- Sets the help menu on this menu bar to be the specified menu.
- Parameters:
- m - the menu to be set as the help menu.
- Since:
- JDK1.0
shortcuts
public synchronized java.util.Enumeration shortcuts()
- Gets an enumeration of all menu shortcuts this menu bar
is managing.
- Returns:
- an enumeration of menu shortcuts that this
menu bar is managing.
- Since:
- JDK1.1
- See Also:
- MenuShortcut
All Packages Class Hierarchy This Package Previous Next Index