java.awt
Class MenuBar

java.lang.Object
  |
  +--java.awt.MenuComponent
        |
        +--java.awt.MenuBar
All Implemented Interfaces:
Accessible, MenuContainer, Serializable

public class MenuBar
extends MenuComponent
implements MenuContainer, Accessible

Unsafe:

See Also:
Serialized Form

Field 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
accessibleContext, actionListenerK, appContext, font, itemListenerK, newEventsOnly, parent, peer
 
Constructor Summary
MenuBar()
          Suppressed: Creates a new menu bar.
 
Method Summary
 Menu add(Menu m)
          Suppressed: Adds the specified menu to the menu bar.
 void addNotify()
          Suppressed: Creates the menu bar's peer.
(package private)  String constructComponentName()
          Construct a name for this MenuComponent.
 int countMenus()
          Suppressed: @deprecated As of JDK version 1.1, replaced by getMenuCount().
 void deleteShortcut(MenuShortcut s)
          Suppressed: Deletes the specified menu shortcut.
 AccessibleContext getAccessibleContext()
          Suppressed: Gets the AccessibleContext associated with this MenuBar.
 Menu getHelpMenu()
          Suppressed: Gets the help menu on the menu bar.
 Menu getMenu(int i)
          Suppressed: Gets the specified menu.
 int getMenuCount()
          Suppressed: Gets the number of menus on the menu bar.
(package private)  int getMenuCountImpl()
           
(package private)  Menu getMenuImpl(int i)
           
 MenuItem getShortcutMenuItem(MenuShortcut s)
          Suppressed: 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)
          Reads the ObjectInputStream.
 void remove(int index)
          Suppressed: Removes the menu located at the specified index from this menu bar.
 void remove(MenuComponent m)
          Suppressed: Removes the specified menu component from this menu bar.
 void removeNotify()
          Suppressed: Removes the menu bar's peer.
 void setHelpMenu(Menu m)
          Suppressed: Sets the specified menu to be this menu bar's help menu.
 Enumeration shortcuts()
          Suppressed: 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, getAccessibleIndexInParent, getAccessibleStateSet, 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, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

menus

Vector menus
This field represents a vector of the actual menus that will be part of the MenuBar.

See Also:
countMenus()

helpMenu

Menu helpMenu
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.

See Also:
getHelpMenu(), setHelpMenu()

base

private static final String base

nameCounter

private static int nameCounter

serialVersionUID

private static final long serialVersionUID

menuBarSerializedDataVersion

private int menuBarSerializedDataVersion
The MenuBar's serialized data version.

Constructor Detail

MenuBar

public MenuBar()
        throws HeadlessException
Suppressed: Creates a new menu bar.

See Also:
java.awt.GraphicsEnvironment#isHeadless
Method Detail

constructComponentName

String constructComponentName()
Construct a name for this MenuComponent. Called by getName() when the name is null.

Overrides:
constructComponentName in class MenuComponent
Returns:
a name for this MenuComponent

addNotify

public void addNotify()
Suppressed: 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.


removeNotify

public void removeNotify()
Suppressed: 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

getHelpMenu

public Menu getHelpMenu()
Suppressed: Gets the help menu on the menu bar.

Returns:
the help menu on this menu bar.

setHelpMenu

public void setHelpMenu(Menu m)
Suppressed: 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

add

public Menu add(Menu m)
Suppressed: Adds the specified menu to the menu bar.

Parameters:
m - the menu to be added.
Returns:
the menu added.
See Also:
java.awt.MenuBar#remove(int), java.awt.MenuBar#remove(java.awt.MenuComponent)

remove

public void remove(int index)
Suppressed: Removes the menu located at the specified index from this menu bar.

Parameters:
index - the position of the menu to be removed.
See Also:
java.awt.MenuBar#add(java.awt.Menu)

remove

public void remove(MenuComponent m)
Suppressed: Removes the specified menu component from this menu bar.

Specified by:
remove in interface MenuContainer
Parameters:
m - the menu component to be removed.
See Also:
java.awt.MenuBar#add(java.awt.Menu)

getMenuCount

public int getMenuCount()
Suppressed: Gets the number of menus on the menu bar.

Returns:
the number of menus on the menu bar.
Since:
JDK1.1

countMenus

public int countMenus()
Suppressed: @deprecated As of JDK version 1.1, replaced by getMenuCount().


getMenuCountImpl

final int getMenuCountImpl()

getMenu

public Menu getMenu(int i)
Suppressed: 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.

getMenuImpl

final Menu getMenuImpl(int i)

shortcuts

public Enumeration shortcuts()
Suppressed: 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:
java.awt.MenuShortcut

getShortcutMenuItem

public MenuItem getShortcutMenuItem(MenuShortcut s)
Suppressed: 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:
java.awt.MenuItem, java.awt.MenuShortcut

handleShortcut

boolean handleShortcut(KeyEvent e)

deleteShortcut

public void deleteShortcut(MenuShortcut s)
Suppressed: Deletes the specified menu shortcut.

Parameters:
s - the menu shortcut to delete.
Since:
JDK1.1

writeObject

private void writeObject(ObjectOutputStream s)
                  throws ClassNotFoundException,
                         IOException
Writes default serializable fields to stream.

Parameters:
s - the ObjectOutputStream to write
ClassNotFoundException
IOException
See Also:
AWTEventMulticaster.save(ObjectOutputStream, String, EventListener), readObject(java.io.ObjectInputStream)

readObject

private void readObject(ObjectInputStream s)
                 throws ClassNotFoundException,
                        IOException,
                        HeadlessException
Reads the ObjectInputStream. Unrecognized keys or values will be ignored.

Parameters:
s - the ObjectInputStream to read
ClassNotFoundException
IOException
HeadlessException
See Also:
java.awt.GraphicsEnvironment#isHeadless, readObject(java.io.ObjectInputStream)

initIDs

private static void initIDs()
Initialize JNI field and method IDs


getAccessibleContext

public AccessibleContext getAccessibleContext()
Suppressed: 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.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class MenuComponent
Returns:
an AccessibleAWTMenuBar that serves as the AccessibleContext of this MenuBar


comments?