The MenuBar class encapsulates the platform's
concept of a menu bar bound to a frame.
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,
MenuBar.shortcuts() and
MenuBar.getShortcutMenuItem(java.awt.MenuShortcut)
that retrieve information about the shortcuts a given
menu bar is managing.
Adds the specified menu to the menu bar. If the menu has been part of another menu bar, removes it from that menu bar.
Returns:
the menu added
Parameters: - m - the menu to be added
See Also:MenuBar.remove(int),
MenuBar.remove(java.awt.MenuComponent),
public void
addNotify
()
Creates the menu bar's peer.
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.
Gets the AccessibleContext associated with this MenuBar.
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.
Returns:
an AccessibleAWTMenuBar that serves as the
AccessibleContext of this MenuBar
Since:
1.3
pack-private int
getAccessibleIndexInParent
()
[Inherited From MenuComponent]
Gets the index of this object in its accessible parent.
Gets the index of this object in its accessible parent.
Returns:
-1 if this object does not have an accessible parent;
otherwise, the index of the child in its accessible parent.
Gets the font used for this menu component.
Returns:
the font used in this menu component, if there is one;
null otherwise
See Also:MenuComponent.setFont(java.awt.Font),
Returns the parent container for this menu component.
Returns the parent container for this menu component.
Returns:
the menu component containing this menu component,
or null if this menu component
is the outermost component, the menu bar itself
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.
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.
Parameters: - s - the specified menu shortcut.
Since:
JDK1.1
See Also:MenuItem,
MenuShortcut,
Gets this component's locking object (the object that owns the thread
sychronization monitor) for AWT component-tree and layout
operations.
Gets this component's locking object (the object that owns the thread sychronization monitor) for AWT component-tree and layout operations.
Returns:
this component's locking object
Returns a string representing the state of this
MenuComponent.
Returns a string representing the state of this MenuComponent. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
Returns:
the parameter string of this menu component
Posts the specified event to the menu. This method is part of the Java 1.0 event system and it is maintained only for backwards compatibility. Its use is discouraged, and it may not be supported in the future.
Parameters: - evt - the event which is to take place
Processes events occurring on this menu component.
Processes events occurring on this menu component.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
Parameters: - e - the event
Since:
JDK1.1
public void
remove
(int index)
Removes the menu located at the specified
index from this menu bar.
Removes the menu located at the specified index from this menu bar.
Parameters: - index - the position of the menu to be removed.
See Also:MenuBar.add(java.awt.Menu),
Sets the font to be used for this menu component to the specified
font.
Sets the font to be used for this menu component to the specified
font. This font is also used by all subcomponents of this menu
component, unless those subcomponents specify a different font.
Some platforms may not support setting of all font attributes
of a menu component; in such cases, calling setFont
will have no effect on the unsupported font attributes of this
menu component. Unless subcomponents of this menu component
specify a different font, this font will be used by those
subcomponents if supported by the underlying platform.
Parameters: - f - the font to be set
See Also:MenuComponent.getFont(),
Font.getAttributes(),
TextAttribute,
Sets the specified menu to be this menu bar's help menu.
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.
Parameters: - m - the menu to be set as the help menu
Sets the name of the component to the specified string.
Sets the name of the component to the specified string.
Parameters: - name - the name of the menu component
Since:
JDK1.1
See Also:MenuComponent.getName(),
Gets an enumeration of all menu shortcuts this menu bar
is managing.
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,
This menu is a special menu dedicated to help. The one thing to note about this menu is that on some platforms it appears at the right edge of the menubar.
Serial: See Also:MenuBar.getHelpMenu(),
MenuBar.setHelpMenu(Menu),
pack-privatefinalstaticString itemListenerK
= "itemL"
[Inherited From MenuComponent]