java::awt::MenuBar Class Reference

Inheritance diagram for java::awt::MenuBar:

Inheritance graph
java::awt::MenuComponentjava::lang::Objectjava::lang::Interfacejava::lang::Syncjava::lang::Lockjava::lang::ScopeAdapterjava::awt::MenuContainer
[legend]
Collaboration diagram for java::awt::MenuBar:

Collaboration graph
java::awt::MenuComponentjava::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::lang::Syncjava::lang::Lockjava::lang::ScopeAdapterjava::lang::Comparablejava::awt::MenuContainer
[legend]

List of all members.


Detailed Description

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:

<img src="doc-files/MenuBar-1.gif" <alt="Diagram of MenuBar containing 2 menus: Examples and Options. Examples menu is expanded showing items: Basic, Simple, Check, and More Examples."> ALIGN=center HSPACE=10 VSPACE=7>

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 that retrieve information about the shortcuts a given menu bar is managing.

Version:
1.63, 01/23/03
Author:
Sami Shaio
See also:
java.awt.Frame

java.awt.Frame::setMenuBar(java.awt.MenuBar)

java.awt.Menu

java.awt.MenuItem

java.awt.MenuShortcut

Since:
JDK1.0

Public Member Functions

 MenuBar ()
 Creates a new menu bar.
virtual Ref< FontgetFont () const
 Gets the font used for this menu component.
virtual Ref< MenugetHelpMenu () const
 Gets the help menu on the menu bar.
virtual void setHelpMenu (const Ref< Menu > &m)
 Sets the specified menu to be this menu bar's help menu.
virtual Ref< Menuadd (const Ref< Menu > &m)
 Adds the specified menu to the menu bar.
virtual void remove (const Ref< MenuComponent > &comp)
 Removes the specified menu component from this menu bar.
virtual void remove (jint index)
 Removes the menu located at the specified index from this menu bar.
virtual jint getMenuCount () const
 Gets the number of menus on the menu bar.
virtual Ref< MenugetMenu (jint index) const
 Gets the specified menu.
Ref< Listshortcuts () const
 Gets an enumeration of all menu shortcuts this menu bar is managing.
Ref< MenuItemgetShortcutMenuItem (const Ref< MenuShortcut > &s) const
 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 deleteShortcut (const Ref< MenuShortcut > &s)
 Deletes the specified menu shortcut.
virtual String toString () const
 Returns a representation of this menu component as a string.

Constructor & Destructor Documentation

java::awt::MenuBar::MenuBar (  ) 

Creates a new menu bar.

Exceptions:
HeadlessException if GraphicsEnvironment.isHeadless() returns true.
See also:
java.awt.GraphicsEnvironment::isHeadless


Member Function Documentation

virtual Ref<Font> java::awt::MenuBar::getFont (  )  const [virtual]

Gets the font used for this menu component.

Returns:
the font used in this menu component, if there is one; null otherwise
See also:
java.awt.MenuComponent::setFont

Reimplemented from java::awt::MenuComponent.

virtual Ref<Menu> java::awt::MenuBar::getHelpMenu (  )  const [virtual]

Gets the help menu on the menu bar.

Returns:
the help menu on this menu bar.

virtual void java::awt::MenuBar::setHelpMenu ( const Ref< Menu > &  m  )  [virtual]

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

virtual Ref<Menu> java::awt::MenuBar::add ( const Ref< Menu > &  m  )  [virtual]

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)

virtual void java::awt::MenuBar::remove ( const Ref< MenuComponent > &  comp  )  [virtual]

Removes the specified menu component from this menu bar.

Parameters:
m the menu component to be removed.
See also:
java.awt.MenuBar::add(java.awt.Menu)

Implements java::awt::MenuContainer.

virtual void java::awt::MenuBar::remove ( jint  index  )  [virtual]

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)

virtual jint java::awt::MenuBar::getMenuCount (  )  const [virtual]

Gets the number of menus on the menu bar.

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

virtual Ref<Menu> java::awt::MenuBar::getMenu ( jint  index  )  const [virtual]

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.

Ref<List> java::awt::MenuBar::shortcuts (  )  const

Gets an enumeration of all menu shortcuts this menu bar is managing.

Returns:
an enumeration of menu shortcuts that this menu bar is managing.
See also:
java.awt.MenuShortcut
Since:
JDK1.1

Ref<MenuItem> java::awt::MenuBar::getShortcutMenuItem ( const Ref< MenuShortcut > &  s  )  const

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.
See also:
java.awt.MenuItem

java.awt.MenuShortcut

Since:
JDK1.1

void java::awt::MenuBar::deleteShortcut ( const Ref< MenuShortcut > &  s  ) 

Deletes the specified menu shortcut.

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

virtual String java::awt::MenuBar::toString (  )  const [virtual]

Returns a representation of this menu component as a string.

Returns:
a string representation of this menu component

Reimplemented from java::awt::MenuComponent.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:06 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3