|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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(java.awt.MenuShortcut)
that retrieve information about the shortcuts a given
menu bar is managing.
Frame
,
Frame.setMenuBar(java.awt.MenuBar)
,
Menu
,
MenuItem
,
MenuShortcut
, Serialized FormField Summary | |
private static String |
base
|
(package private) Menu |
helpMenu
This menu is a special menu dedicated to help. |
private int |
menuBarSerializedDataVersion
The MenuBar's serialized data version. |
(package private) Vector |
menus
This field represents a vector of the actual menus that will be part of the MenuBar. |
private static int |
nameCounter
|
private static long |
serialVersionUID
|
Fields inherited from class java.awt.MenuComponent |
actionListenerK,
appContext,
font,
itemListenerK,
name,
nameExplicitlySet,
newEventsOnly,
parent,
peer,
serialVersionUID |
Constructor Summary | |
MenuBar()
Creates a new menu bar. |
Method Summary | |
(package private) static void |
|
Menu |
add(Menu m)
Adds the specified menu to the menu bar. |
void |
addNotify()
Creates the menu bar's peer. |
(package private) String |
constructComponentName()
Construct a name for this MenuComponent. |
int |
countMenus()
Deprecated. As of JDK version 1.1, replaced by getMenuCount() . |
void |
deleteShortcut(MenuShortcut s)
Deletes the specified menu shortcut. |
Menu |
getHelpMenu()
Gets the help menu on the menu bar. |
Menu |
getMenu(int i)
Gets the specified menu. |
int |
getMenuCount()
Gets the number of menus on the menu bar. |
(package private) int |
getMenuCountImpl()
|
(package private) Menu |
getMenuImpl(int i)
|
MenuItem |
getShortcutMenuItem(MenuShortcut s)
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. |
(package private) boolean |
handleShortcut(KeyEvent e)
|
private static void |
initIDs()
Initialize JNI field and method IDs |
private void |
readObject(ObjectInputStream s)
Read the ObjectInputStream and if it isnt null add a listener to receive item events fired by the MenuBar. |
void |
remove(int index)
Removes the menu located at the specified index from this menu bar. |
void |
remove(MenuComponent m)
Removes the specified menu component from this menu bar. |
void |
removeNotify()
Removes the menu bar's peer. |
void |
setHelpMenu(Menu m)
Sets the help menu on this menu bar to be the specified menu. |
Enumeration |
shortcuts()
Gets an enumeration of all menu shortcuts this menu bar is managing. |
private void |
writeObject(ObjectOutputStream s)
Writes default serializable fields to stream. |
Methods inherited from class java.awt.MenuComponent |
dispatchEvent,
dispatchEventImpl,
eventEnabled,
getFont_NoClientCode,
getFont,
getName,
getParent_NoClientCode,
getParent,
getPeer,
getTreeLock,
paramString,
postEvent,
processEvent,
setFont,
setName,
toString |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
Field Detail |
Vector menus
countMenus()
Menu helpMenu
getHelpMenu()
,
setHelpMenu()
private static final String base
private static int nameCounter
private static final long serialVersionUID
private int menuBarSerializedDataVersion
Constructor Detail |
public MenuBar()
Method Detail |
static void()
String constructComponentName()
public void addNotify()
public void removeNotify()
public Menu getHelpMenu()
public void setHelpMenu(Menu m)
m
- the menu to be set as the help menu.public Menu add(Menu m)
m
- the menu to be added.remove(int)
,
remove(java.awt.MenuComponent)
public void remove(int index)
index
- the position of the menu to be removed.add(java.awt.Menu)
public void remove(MenuComponent m)
m
- the menu component to be removed.add(java.awt.Menu)
public int getMenuCount()
public int countMenus()
getMenuCount()
.final int getMenuCountImpl()
public Menu getMenu(int i)
i
- the index position of the menu to be returned.final Menu getMenuImpl(int i)
public Enumeration shortcuts()
MenuShortcut
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.MenuItem
,
MenuShortcut
boolean handleShortcut(KeyEvent e)
public void deleteShortcut(MenuShortcut s)
s
- the menu shortcut to delete.private void writeObject(ObjectOutputStream s) throws ClassNotFoundException, IOException
AWTEventMulticaster.save(ObjectOutputStream, String, EventListener)
,
java.awt.Component.itemListenerK
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
removeActionListener()
,
addActionListener()
private static void initIDs()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |