java::awt::Menu Class Reference

Inheritance diagram for java::awt::Menu:

Inheritance graph
java::awt::MenuItemjava::awt::MenuComponentjava::lang::Objectjava::lang::Interfacejava::lang::Syncjava::awt::event::ActionSourcejava::lang::Lockjava::lang::ScopeAdapterjava::util::EventSourcejava::awt::MenuContainer
[legend]
Collaboration diagram for java::awt::Menu:

Collaboration graph
java::awt::MenuItemjava::awt::MenuComponentjava::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::lang::Syncjava::awt::event::ActionSourcejava::lang::Lockjava::lang::ScopeAdapterjava::lang::Comparablejava::util::EventSourcejava::util::Collectionjava::awt::MenuContainerjava::util::LinkedListjava::util::AbstractSequentialListjava::util::AbstractListjava::util::AbstractCollectionjava::util::List
[legend]

List of all members.


Detailed Description

A Menu object is a pull-down menu component that is deployed from a menu bar.

A menu can optionally be a tear-off menu. A tear-off menu can be opened and dragged away from its parent menu bar or menu. It remains on the screen after the mouse button has been released. The mechanism for tearing off a menu is platform dependent, since the look and feel of the tear-off menu is determined by its peer. On platforms that do not support tear-off menus, the tear-off property is ignored.

Each item in a menu must belong to the MenuItem class. It can be an instance of MenuItem, a submenu (an instance of Menu), or a check box (an instance of CheckboxMenuItem).

Version:
1.71, 01/23/03
Author:
Sami Shaio
See also:
java.awt.MenuItem

java.awt.CheckboxMenuItem

Since:
JDK1.0

Public Member Functions

 Menu (const String &label=nilString, jboolean tearOff=false)
 Constructs a new menu with the specified label, indicating whether the menu can be torn off.
virtual Ref< FontgetFont () const
 Gets the font used for this menu component.
virtual void remove (const Ref< MenuComponent > &comp)
 Removes the specified menu item from this menu.
virtual void remove (jint index)
 Removes the menu item at the specified index from this menu.
virtual void removeAll ()
 Removes all items from this menu.
virtual jboolean isTearOff () const
 Indicates whether this menu is a tear-off menu.
virtual jint getItemCount () const
 Get the number of items in this menu.
virtual Ref< MenuItemgetItem (jint index) const
 Gets the item located at the specified index of this menu.
virtual Ref< MenuItemadd (const Ref< MenuItem > &mi)
 Adds the specified menu item to this menu.
virtual void addLabel (const String &label)
 Adds an item with the specified label to this menu.
virtual void insert (const Ref< MenuItem > &item, jint index)
 Inserts a menu item into this menu at the specified position.
virtual void insertLabel (const String &label, jint index)
 Inserts a menu item with the specified label into this menu at the specified position.
virtual void addSeparator ()
 Adds a separator line, or a hypen, to the menu at the current position.
virtual void insertSeparator (jint index)
 Inserts a separator at the specified position.
virtual String toString () const
 Returns a representation of this menu component as a string.

Constructor & Destructor Documentation

java::awt::Menu::Menu ( const String label = nilString,
jboolean  tearOff = false 
)

Constructs a new menu with the specified label, indicating whether the menu can be torn off.

Tear-off functionality may not be supported by all implementations of AWT. If a particular implementation doesn't support tear-off menus, this value is silently ignored.

Parameters:
label the menu's label in the menu bar, or in another menu of which this menu is a submenu.
tearOff if true, the menu is a tear-off menu.
Exceptions:
HeadlessException if GraphicsEnvironment.isHeadless() returns true.
See also:
java.awt.GraphicsEnvironment::isHeadless
Since:
JDK1.0.


Member Function Documentation

virtual Ref<Font> java::awt::Menu::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

Implements java::awt::MenuContainer.

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

Removes the specified menu item from this menu.

Parameters:
item the item to be removed from the menu. If item is null or is not in this menu, this method does nothing.

Implements java::awt::MenuContainer.

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

Removes the menu item at the specified index from this menu.

Parameters:
index the position of the item to be removed.

virtual void java::awt::Menu::removeAll (  )  [virtual]

Removes all items from this menu.

Since:
JDK1.0.

virtual jboolean java::awt::Menu::isTearOff (  )  const [virtual]

Indicates whether this menu is a tear-off menu.

Tear-off functionality may not be supported by all implementations of AWT. If a particular implementation doesn't support tear-off menus, this value is silently ignored.

Returns:
true if this is a tear-off menu; false otherwise.

virtual jint java::awt::Menu::getItemCount (  )  const [virtual]

Get the number of items in this menu.

Returns:
the number of items in this menu.
Since:
JDK1.1

virtual Ref<MenuItem> java::awt::Menu::getItem ( jint  index  )  const [virtual]

Gets the item located at the specified index of this menu.

Parameters:
index the position of the item to be returned.
Returns:
the item located at the specified index.

virtual Ref<MenuItem> java::awt::Menu::add ( const Ref< MenuItem > &  mi  )  [virtual]

Adds the specified menu item to this menu.

If the menu item has been part of another menu, removes it from that menu.

Parameters:
mi the menu item to be added
Returns:
the menu item added
See also:
java.awt.Menu::insert(java.lang.String, int)

java.awt.Menu::insert(java.awt.MenuItem, int)

virtual void java::awt::Menu::addLabel ( const String label  )  [virtual]

Adds an item with the specified label to this menu.

Parameters:
label the text on the item
See also:
java.awt.Menu::insert(java.lang.String, int)

java.awt.Menu::insert(java.awt.MenuItem, int)

virtual void java::awt::Menu::insert ( const Ref< MenuItem > &  item,
jint  index 
) [virtual]

Inserts a menu item into this menu at the specified position.

Parameters:
menuitem the menu item to be inserted.
index the position at which the menu item should be inserted.
See also:
java.awt.Menu::add(java.lang.String)

java.awt.Menu::add(java.awt.MenuItem)

Exceptions:
IllegalArgumentException if the value of index is less than zero
Since:
JDK1.1

virtual void java::awt::Menu::insertLabel ( const String label,
jint  index 
) [virtual]

Inserts a menu item with the specified label into this menu at the specified position.

This is a convenience method for insert(menuItem, index).

Parameters:
label the text on the item
index the position at which the menu item should be inserted
See also:
java.awt.Menu::add(java.lang.String)

java.awt.Menu::add(java.awt.MenuItem)

Exceptions:
IllegalArgumentException if the value of index is less than zero
Since:
JDK1.1

virtual void java::awt::Menu::addSeparator (  )  [virtual]

Adds a separator line, or a hypen, to the menu at the current position.

See also:
java.awt.Menu::insertSeparator(int)

virtual void java::awt::Menu::insertSeparator ( jint  index  )  [virtual]

Inserts a separator at the specified position.

Parameters:
index the position at which the menu separator should be inserted.
Exceptions:
IllegalArgumentException if the value of index is less than 0.
See also:
java.awt.Menu::addSeparator
Since:
JDK1.1

virtual String java::awt::Menu::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::MenuItem.


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