<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.awt.MenuItem
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.awt.html">This Package</a>  <a href="java.awt.MenuComponent.html#_top_">Previous</a>  <a href="java.awt.MenuShortcut.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.awt.MenuItem
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----<a href="java.awt.MenuComponent.html#_top_">java.awt.MenuComponent</a>
           |
           +----java.awt.MenuItem
</pre>
<hr>
<dl>
  <dt> public class <b>MenuItem</b>
  <dt> extends <a href="java.awt.MenuComponent.html#_top_">MenuComponent</a>
</dl>
All items in a menu must belong to the class
 <code>MenuItem</code>, or one of its subclasses.
 <p>
 The default <code>MenuItem</code> object embodies
 a simple labeled menu item.
 <p>
 This picture of a menu bar shows five menu items:
 <IMG SRC="images-awt/MenuBar-1.gif"
 ALIGN=CENTER HSPACE=10 VSPACE=7>
 <br CLEAR=LEFT>
 The first two items are simple menu items, labeled
 <code>"Basic"</code> and <code>"Simple"</code>.
 Following these two items is a separator, which is itself
 a menu item, created with the label <code>"-"</code>.
 Next is an instance of <code>CheckboxMenuItem</code>
 labeled <code>"Check"</code>. The final menu item is a
 submenu labeled <code>"More&nbsp;Examples"</code>,
 and this submenu is an instance of <code>Menu</code>.
 <p>
 When a menu item is selected, AWT sends an action event to
 the menu item. Since the event is an
 instance of <code>ActionEvent</code>, the <code>processEvent</code>
 method examines the event and passes it along to
 <code>processActionEvent</code>. The latter method redirects the
 event to any <code>ActionListener</code> objects that have
 registered an interest in action events generated by this
 menu item.
 <P>
 Note that the subclass <code>Menu</code> overrides this behavior and
 does not send any event to the frame until one of its subitems is
 selected.
<p>
<hr>
<a name="index"></a>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#MenuItem()"><b>MenuItem</b></a>()
  <dd>  Constructs a new MenuItem with an empty label and no keyboard
 shortcut.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#MenuItem(java.lang.String)"><b>MenuItem</b></a>(String)
  <dd>  Constructs a new MenuItem with the specified label
 and no keyboard shortcut.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#MenuItem(java.lang.String, java.awt.MenuShortcut)"><b>MenuItem</b></a>(String, MenuShortcut)
  <dd>  Create a menu item with an associated keyboard shortcut.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#addActionListener(java.awt.event.ActionListener)"><b>addActionListener</b></a>(ActionListener)
  <dd>  Adds the specified action listener to receive action events
 from this menu item.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#addNotify()"><b>addNotify</b></a>()
  <dd>  Creates the menu item's peer.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#deleteShortcut()"><b>deleteShortcut</b></a>()
  <dd>  Delete any <code>MenuShortcut</code> object associated
 with this menu item.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#disable()"><b>disable</b></a>()
  <dd>  
<b>Deprecated.</b>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#disableEvents(long)"><b>disableEvents</b></a>(long)
  <dd>  Disables event delivery to this menu item for events
 defined by the specified event mask parameter.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#enable()"><b>enable</b></a>()
  <dd>  
<b>Deprecated.</b>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#enable(boolean)"><b>enable</b></a>(boolean)
  <dd>  
<b>Deprecated.</b>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#enableEvents(long)"><b>enableEvents</b></a>(long)
  <dd>  Enables event delivery to this menu item for events
 to be defined by the specified event mask parameter
 <p>
 Since event types are automatically enabled when a listener for
 that type is added to the menu item, this method only needs
 to be invoked by subclasses of <code>MenuItem</code> which desire to
 have the specified event types delivered to <code>processEvent</code>
 regardless of whether a listener is registered.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getActionCommand()"><b>getActionCommand</b></a>()
  <dd>  Gets the command name of the action event that is fired
 by this menu item.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getLabel()"><b>getLabel</b></a>()
  <dd>  Gets the label for this menu item.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getShortcut()"><b>getShortcut</b></a>()
  <dd>  Get the <code>MenuShortcut</code> object associated with this
 menu item,
 
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#isEnabled()"><b>isEnabled</b></a>()
  <dd>  Checks whether this menu item is enabled.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#paramString()"><b>paramString</b></a>()
  <dd>  Returns the parameter string representing the state of this menu
 item.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#processActionEvent(java.awt.event.ActionEvent)"><b>processActionEvent</b></a>(ActionEvent)
  <dd>  Processes action events occurring on this menu item,
 by dispatching them to any registered
 <code>ActionListener</code> objects.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#processEvent(java.awt.AWTEvent)"><b>processEvent</b></a>(AWTEvent)
  <dd>  Processes events on this menu item.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#removeActionListener(java.awt.event.ActionListener)"><b>removeActionListener</b></a>(ActionListener)
  <dd>  Removes the specified action listener so it no longer receives
 action events from this menu item.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setActionCommand(java.lang.String)"><b>setActionCommand</b></a>(String)
  <dd>  Sets the command name of the action event that is fired
 by this menu item.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setEnabled(boolean)"><b>setEnabled</b></a>(boolean)
  <dd>  Sets whether or not this menu item can be chosen.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setLabel(java.lang.String)"><b>setLabel</b></a>(String)
  <dd>  Sets the label for this menu item to the specified label.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setShortcut(java.awt.MenuShortcut)"><b>setShortcut</b></a>(MenuShortcut)
  <dd>  Set the <code>MenuShortcut</code> object associated with this
 menu item.
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="MenuItem"></a>
<a name="MenuItem()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>MenuItem</b>
<pre>
 public MenuItem()
</pre>
<dl>
  <dd> Constructs a new MenuItem with an empty label and no keyboard
 shortcut.
<p>
</dl>
<a name="MenuItem(java.lang.String)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>MenuItem</b>
<pre>
 public MenuItem(<a href="java.lang.String.html#_top_">String</a> label)
</pre>
<dl>
  <dd> Constructs a new MenuItem with the specified label
 and no 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.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> label - the label for this menu item.
  </dl></dd>
</dl>
<a name="MenuItem(java.lang.String, java.awt.MenuShortcut)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>MenuItem</b>
<pre>
 public MenuItem(<a href="java.lang.String.html#_top_">String</a> label,
                 <a href="java.awt.MenuShortcut.html#_top_">MenuShortcut</a> s)
</pre>
<dl>
  <dd> 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.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> label - the label for this menu item.
    <dd> s - the instance of <code>MenuShortcut</code>
                       associated with this menu item.
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="addNotify()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="addNotify"><b>addNotify</b></a>
<pre>
 public void addNotify()
</pre>
<dl>
  <dd> Creates the menu item's peer.  The peer allows us to modify the
 appearance of the menu item without changing its functionality.
<p>
</dl>
<a name="getLabel()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getLabel"><b>getLabel</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> getLabel()
</pre>
<dl>
  <dd> Gets the label for this menu item.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the label of this menu item, or <code>null</code>
if this menu item has no label.
    <dt> <b>See Also:</b>
    <dd> <a href="#setLabel">setLabel</a>
  </dl></dd>
</dl>
<a name="setLabel(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setLabel"><b>setLabel</b></a>
<pre>
 public synchronized void setLabel(<a href="java.lang.String.html#_top_">String</a> label)
</pre>
<dl>
  <dd> Sets the label for this menu item to the specified label.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> label - the new label, or <code>null</code> for no label.
    <dt> <b>See Also:</b>
    <dd> <a href="#getLabel">getLabel</a>
  </dl></dd>
</dl>
<a name="isEnabled()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="isEnabled"><b>isEnabled</b></a>
<pre>
 public boolean isEnabled()
</pre>
<dl>
  <dd> Checks whether this menu item is enabled.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#setEnabled">setEnabled</a>
  </dl></dd>
</dl>
<a name="setEnabled(boolean)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setEnabled"><b>setEnabled</b></a>
<pre>
 public synchronized void setEnabled(boolean b)
</pre>
<dl>
  <dd> Sets whether or not this menu item can be chosen.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> b - if <code>true</code>, enables this menu item;
                       if <code>false</code>, disables it.
    <dt> <b>See Also:</b>
    <dd> <a href="#isEnabled">isEnabled</a>
  </dl></dd>
</dl>
<a name="enable()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="enable"><b>enable</b></a>
<pre>
 public synchronized void enable()
</pre>
<dl>
<dd><b> Note: enable() is deprecated.</b>
<i>As of JDK version 1.1,
 replaced by <code>setEnabled(boolean)</code>.</i>
<p>
</dl>
<a name="enable(boolean)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="enable"><b>enable</b></a>
<pre>
 public void enable(boolean b)
</pre>
<dl>
<dd><b> Note: enable() is deprecated.</b>
<i>As of JDK version 1.1,
 replaced by <code>setEnabled(boolean)</code>.</i>
<p>
</dl>
<a name="disable()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="disable"><b>disable</b></a>
<pre>
 public synchronized void disable()
</pre>
<dl>
<dd><b> Note: disable() is deprecated.</b>
<i>As of JDK version 1.1,
 replaced by <code>setEnabled(boolean)</code>.</i>
<p>
</dl>
<a name="getShortcut()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getShortcut"><b>getShortcut</b></a>
<pre>
 public <a href="java.awt.MenuShortcut.html#_top_">MenuShortcut</a> getShortcut()
</pre>
<dl>
  <dd> Get the <code>MenuShortcut</code> object associated with this
 menu item,
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the menu shortcut associated with this menu item,
                   or <code>null</code> if none has been specified.
    <dt> <b>See Also:</b>
    <dd> <a href="#setShortcut">setShortcut</a>
  </dl></dd>
</dl>
<a name="setShortcut(java.awt.MenuShortcut)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setShortcut"><b>setShortcut</b></a>
<pre>
 public void setShortcut(<a href="java.awt.MenuShortcut.html#_top_">MenuShortcut</a> s)
</pre>
<dl>
  <dd> Set the <code>MenuShortcut</code> object associated with this
 menu item. If a menu shortcut is already associated with
 this menu item, it is replaced.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> s - the menu shortcut to associate
                           with this menu item.
    <dt> <b>See Also:</b>
    <dd> <a href="#getShortcut">getShortcut</a>
  </dl></dd>
</dl>
<a name="deleteShortcut()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="deleteShortcut"><b>deleteShortcut</b></a>
<pre>
 public void deleteShortcut()
</pre>
<dl>
  <dd> Delete any <code>MenuShortcut</code> object associated
 with this menu item.
<p>
</dl>
<a name="enableEvents(long)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="enableEvents"><b>enableEvents</b></a>
<pre>
 protected final void enableEvents(long eventsToEnable)
</pre>
<dl>
  <dd> Enables event delivery to this menu item for events
 to be defined by the specified event mask parameter
 <p>
 Since event types are automatically enabled when a listener for
 that type is added to the menu item, this method only needs
 to be invoked by subclasses of <code>MenuItem</code> which desire to
 have the specified event types delivered to <code>processEvent</code>
 regardless of whether a listener is registered.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> eventsToEnable - the event mask defining the event types.
    <dt> <b>See Also:</b>
    <dd> <a href="#processEvent">processEvent</a>, <a href="#disableEvents">disableEvents</a>, <a href="java.awt.Component.html#enableEvents">enableEvents</a>
  </dl></dd>
</dl>
<a name="disableEvents(long)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="disableEvents"><b>disableEvents</b></a>
<pre>
 protected final void disableEvents(long eventsToDisable)
</pre>
<dl>
  <dd> Disables event delivery to this menu item for events
 defined by the specified event mask parameter.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> eventsToDisable - the event mask defining the event types.
    <dt> <b>See Also:</b>
    <dd> <a href="#processEvent">processEvent</a>, <a href="#enableEvents">enableEvents</a>, <a href="java.awt.Component.html#disableEvents">disableEvents</a>
  </dl></dd>
</dl>
<a name="setActionCommand(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setActionCommand"><b>setActionCommand</b></a>
<pre>
 public void setActionCommand(<a href="java.lang.String.html#_top_">String</a> command)
</pre>
<dl>
  <dd> Sets the command name of the action event that is fired
 by this menu item.
 <p>
 By default, the action command is set to the label of
 the menu item.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> command - the action command to be set
                                for this menu item.
    <dt> <b>See Also:</b>
    <dd> <a href="#getActionCommand">getActionCommand</a>
  </dl></dd>
</dl>
<a name="getActionCommand()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getActionCommand"><b>getActionCommand</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> getActionCommand()
</pre>
<dl>
  <dd> Gets the command name of the action event that is fired
 by this menu item.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#setActionCommand">setActionCommand</a>
  </dl></dd>
</dl>
<a name="addActionListener(java.awt.event.ActionListener)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="addActionListener"><b>addActionListener</b></a>
<pre>
 public synchronized void addActionListener(<a href="java.awt.event.ActionListener.html#_top_">ActionListener</a> l)
</pre>
<dl>
  <dd> Adds the specified action listener to receive action events
 from this menu item.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> l - the action listener.
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.event.ActionEvent.html#_top_">ActionEvent</a>, <a href="java.awt.event.ActionListener.html#_top_">ActionListener</a>, <a href="#removeActionListener">removeActionListener</a>
  </dl></dd>
</dl>
<a name="removeActionListener(java.awt.event.ActionListener)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="removeActionListener"><b>removeActionListener</b></a>
<pre>
 public synchronized void removeActionListener(<a href="java.awt.event.ActionListener.html#_top_">ActionListener</a> l)
</pre>
<dl>
  <dd> Removes the specified action listener so it no longer receives
 action events from this menu item.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> l - the action listener.
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.event.ActionEvent.html#_top_">ActionEvent</a>, <a href="java.awt.event.ActionListener.html#_top_">ActionListener</a>, <a href="#addActionListener">addActionListener</a>
  </dl></dd>
</dl>
<a name="processEvent(java.awt.AWTEvent)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="processEvent"><b>processEvent</b></a>
<pre>
 protected void processEvent(<a href="java.awt.AWTEvent.html#_top_">AWTEvent</a> e)
</pre>
<dl>
  <dd> Processes events on this menu item. If the event is an
 instance of <code>ActionEvent</code>, it invokes
 <code>processActionEvent</code>, another method
 defined by <code>MenuItem</code>.
 <p>
 Currently, menu items only support action events.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> e - the event.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.awt.MenuComponent.html#processEvent(java.awt.AWTEvent)">processEvent</a> in class <a href="java.awt.MenuComponent.html#_top_">MenuComponent</a>
    <dt> <b>See Also:</b>
    <dd> <a href="#processActionEvent">processActionEvent</a>
  </dl></dd>
</dl>
<a name="processActionEvent(java.awt.event.ActionEvent)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="processActionEvent"><b>processActionEvent</b></a>
<pre>
 protected void processActionEvent(<a href="java.awt.event.ActionEvent.html#_top_">ActionEvent</a> e)
</pre>
<dl>
  <dd> Processes action events occurring on this menu item,
 by dispatching them to any registered
 <code>ActionListener</code> objects.
 This method is not called unless action events are
 enabled for this component. Action events are enabled
 when one of the following occurs:
 <p><ul>
 <li>An <code>ActionListener</code> object is registered
 via <code>addActionListener</code>.
 <li>Action events are enabled via <code>enableEvents</code>.
 </ul>
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> e - the action event.
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.event.ActionEvent.html#_top_">ActionEvent</a>, <a href="java.awt.event.ActionListener.html#_top_">ActionListener</a>, <a href="#enableEvents">enableEvents</a>
  </dl></dd>
</dl>
<a name="paramString()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="paramString"><b>paramString</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> paramString()
</pre>
<dl>
  <dd> Returns the parameter string representing the state of this menu
 item. This string is useful for debugging.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the parameter string of this menu item.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.awt.MenuComponent.html#paramString()">paramString</a> in class <a href="java.awt.MenuComponent.html#_top_">MenuComponent</a>
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.awt.html">This Package</a>  <a href="java.awt.MenuComponent.html#_top_">Previous</a>  <a href="java.awt.MenuShortcut.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
