java::awt::MenuItem Class Reference

Inheritance diagram for java::awt::MenuItem:

Inheritance graph
java::awt::CheckboxMenuItemjava::awt::Menujava::awt::MenuComponentjava::lang::Objectjava::lang::Interfacejava::lang::Syncjava::awt::event::ActionSourcejava::lang::Lockjava::lang::ScopeAdapterjava::util::EventSource
[legend]
Collaboration diagram for java::awt::MenuItem:

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

List of all members.


Detailed Description

All items in a menu must belong to the class MenuItem, or one of its subclasses.

The default MenuItem object embodies a simple labeled menu item.

This picture of a menu bar shows five menu items:

MenuBar-1.gif

The first two items are simple menu items, labeled "Basic" and "Simple". Following these two items is a separator, which is itself a menu item, created with the label "-". Next is an instance of CheckboxMenuItem labeled "Check". The final menu item is a submenu labeled "More Examples", and this submenu is an instance of Menu.

When a menu item is selected, AWT sends an action event to the menu item. Since the event is an instance of ActionEvent, the processEvent method examines the event and passes it along to processActionEvent. The latter method redirects the event to any ActionListener objects that have registered an interest in action events generated by this menu item.

Note that the subclass Menu overrides this behavior and does not send any event to the frame until one of its subitems is selected.

Version:
1.83, 01/23/03
Author:
Sami Shaio

Public Member Functions

 MenuItem (const String &label=nilString, const Ref< MenuShortcut > &s=0)
 Create a menu item with an associated keyboard shortcut.
virtual String getLabel () const
 Gets the label for this menu item.
virtual void setLabel (const String &label)
 Sets the label for this menu item to the specified label.
virtual jboolean isEnabled () const
 Checks whether this menu item is enabled.
virtual void setEnabled (jboolean b)
 Sets whether or not this menu item can be chosen.
virtual Ref
< MenuShortcut
getShortcut () const
 Get the MenuShortcut object associated with this menu item,.
virtual void setShortcut (const Ref< MenuShortcut > &s)
 Set the MenuShortcut object associated with this menu item.
virtual void deleteShortcut ()
 Delete any MenuShortcut object associated with this menu item.
virtual void setActionCommand (const String &command)
 Sets the command name of the action event that is fired by this menu item.
virtual String getActionCommand () const
 Gets the command name of the action event that is fired by this menu item.
virtual String toString () const
 Returns a representation of this menu component as a string.

Protected Member Functions

 MenuItem (const Object *_impl)

Constructor & Destructor Documentation

java::awt::MenuItem::MenuItem ( const String label = nilString,
const Ref< MenuShortcut > &  s = 0 
)

Create a menu item with an associated keyboard shortcut.

Note that use of "-" in a label is reserved to indicate a separator between menu items. By default, all menu items except for separators are enabled.

Parameters:
label the label for this menu item.
s the instance of MenuShortcut associated with this menu item.
Exceptions:
HeadlessException if GraphicsEnvironment.isHeadless() returns true.
See also:
java.awt.GraphicsEnvironment::isHeadless
Since:
JDK1.1

java::awt::MenuItem::MenuItem ( const Object _impl  )  [protected]


Member Function Documentation

virtual String java::awt::MenuItem::getLabel (  )  const [virtual]

Gets the label for this menu item.

Returns:
the label of this menu item, or null if this menu item has no label.
See also:
java.awt.MenuItem::setLabel
Since:
JDK1.0

virtual void java::awt::MenuItem::setLabel ( const String label  )  [virtual]

Sets the label for this menu item to the specified label.

Parameters:
label the new label, or null for no label.
See also:
java.awt.MenuItem::getLabel
Since:
JDK1.0

virtual jboolean java::awt::MenuItem::isEnabled (  )  const [virtual]

Checks whether this menu item is enabled.

See also:
java.awt.MenuItem::setEnabled
Since:
JDK1.0

virtual void java::awt::MenuItem::setEnabled ( jboolean  b  )  [virtual]

Sets whether or not this menu item can be chosen.

Parameters:
b if true, enables this menu item; if false, disables it.
See also:
java.awt.MenuItem::isEnabled
Since:
JDK1.1

virtual Ref<MenuShortcut> java::awt::MenuItem::getShortcut (  )  const [virtual]

Get the MenuShortcut object associated with this menu item,.

Returns:
the menu shortcut associated with this menu item, or null if none has been specified.
See also:
java.awt.MenuItem::setShortcut
Since:
JDK1.1

virtual void java::awt::MenuItem::setShortcut ( const Ref< MenuShortcut > &  s  )  [virtual]

Set the MenuShortcut object associated with this menu item.

If a menu shortcut is already associated with this menu item, it is replaced.

Parameters:
s the menu shortcut to associate with this menu item.
See also:
java.awt.MenuItem::getShortcut
Since:
JDK1.1

virtual void java::awt::MenuItem::deleteShortcut (  )  [virtual]

Delete any MenuShortcut object associated with this menu item.

Since:
JDK1.1

virtual void java::awt::MenuItem::setActionCommand ( const String command  )  [virtual]

Sets the command name of the action event that is fired by this menu item.

By default, the action command is set to the label of the menu item.

Parameters:
command the action command to be set for this menu item.
See also:
java.awt.MenuItem::getActionCommand
Since:
JDK1.1

virtual String java::awt::MenuItem::getActionCommand (  )  const [virtual]

Gets the command name of the action event that is fired by this menu item.

See also:
java.awt.MenuItem::setActionCommand
Since:
JDK1.1

Implements java::awt::event::ActionSource.

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

Reimplemented in java::awt::CheckboxMenuItem, and java::awt::Menu.


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