< prev index next >
src/java.desktop/share/classes/java/awt/MenuItem.java
Print this page
@@ -33,38 +33,38 @@
import javax.accessibility.*;
import sun.awt.AWTAccessor;
/**
* All items in a menu must belong to the class
- * <code>MenuItem</code>, or one of its subclasses.
+ * {@code MenuItem}, or one of its subclasses.
* <p>
- * The default <code>MenuItem</code> object embodies
+ * The default {@code MenuItem} object embodies
* a simple labeled menu item.
* <p>
* This picture of a menu bar shows five menu items:
* <IMG SRC="doc-files/MenuBar-1.gif" alt="The following text describes this graphic."
* style="float:center; margin: 7px 10px;">
* <br style="clear:left;">
* The first two items are simple menu items, labeled
- * <code>"Basic"</code> and <code>"Simple"</code>.
+ * {@code "Basic"} and {@code "Simple"}.
* 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
+ * a menu item, created with the label {@code "-"}.
+ * Next is an instance of {@code CheckboxMenuItem}
+ * labeled {@code "Check"}. The final menu item is a
* submenu labeled <code>"More Examples"</code>,
- * and this submenu is an instance of <code>Menu</code>.
+ * and this submenu is an instance of {@code Menu}.
* <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>
+ * instance of {@code ActionEvent}, the {@code processEvent}
* 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
+ * {@code processActionEvent}. The latter method redirects the
+ * event to any {@code ActionListener} 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
+ * Note that the subclass {@code Menu} overrides this behavior and
* does not send any event to the frame until one of its subitems is
* selected.
*
* @author Sami Shaio
*/
@@ -101,22 +101,22 @@
});
}
/**
* A value to indicate whether a menu item is enabled
- * or not. If it is enabled, <code>enabled</code> will
- * be set to true. Else <code>enabled</code> will
+ * or not. If it is enabled, {@code enabled} will
+ * be set to true. Else {@code enabled} will
* be set to false.
*
* @serial
* @see #isEnabled()
* @see #setEnabled(boolean)
*/
boolean enabled = true;
/**
- * <code>label</code> is the label of a menu item.
+ * {@code label} is the label of a menu item.
* It can be any string.
*
* @serial
* @see #getLabel()
* @see #setLabel(String)
@@ -124,11 +124,11 @@
String label;
/**
* This field indicates the command tha has been issued
* by a particular menu item.
- * By default the <code>actionCommand</code>
+ * By default the {@code actionCommand}
* is the label of the menu item, unless it has been
* set using setActionCommand.
*
* @serial
* @see #setActionCommand(String)
@@ -202,11 +202,11 @@
* 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.
* @param label the label for this menu item.
- * @param s the instance of <code>MenuShortcut</code>
+ * @param s the instance of {@code MenuShortcut}
* associated with this menu item.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
* @since 1.1
@@ -237,22 +237,22 @@
}
}
/**
* Gets the label for this menu item.
- * @return the label of this menu item, or <code>null</code>
+ * @return the label of this menu item, or {@code null}
if this menu item has no label.
* @see java.awt.MenuItem#setLabel
* @since 1.0
*/
public String getLabel() {
return label;
}
/**
* Sets the label for this menu item to the specified label.
- * @param label the new label, or <code>null</code> for no label.
+ * @param label the new label, or {@code null} for no label.
* @see java.awt.MenuItem#getLabel
* @since 1.0
*/
public synchronized void setLabel(String label) {
this.label = label;
@@ -274,22 +274,22 @@
return enabled;
}
/**
* Sets whether or not this menu item can be chosen.
- * @param b if <code>true</code>, enables this menu item;
- * if <code>false</code>, disables it.
+ * @param b if {@code true}, enables this menu item;
+ * if {@code false}, disables it.
* @see java.awt.MenuItem#isEnabled
* @since 1.1
*/
public synchronized void setEnabled(boolean b) {
enable(b);
}
/**
* @deprecated As of JDK version 1.1,
- * replaced by <code>setEnabled(boolean)</code>.
+ * replaced by {@code setEnabled(boolean)}.
*/
@Deprecated
public synchronized void enable() {
enabled = true;
MenuItemPeer peer = (MenuItemPeer)this.peer;
@@ -302,11 +302,11 @@
* Sets whether or not this menu item can be chosen.
*
* @param b if {@code true}, enables this menu item;
* otherwise disables
* @deprecated As of JDK version 1.1,
- * replaced by <code>setEnabled(boolean)</code>.
+ * replaced by {@code setEnabled(boolean)}.
*/
@Deprecated
public void enable(boolean b) {
if (b) {
enable();
@@ -315,11 +315,11 @@
}
}
/**
* @deprecated As of JDK version 1.1,
- * replaced by <code>setEnabled(boolean)</code>.
+ * replaced by {@code setEnabled(boolean)}.
*/
@Deprecated
public synchronized void disable() {
enabled = false;
MenuItemPeer peer = (MenuItemPeer)this.peer;
@@ -327,23 +327,23 @@
peer.setEnabled(false);
}
}
/**
- * Get the <code>MenuShortcut</code> object associated with this
+ * Get the {@code MenuShortcut} object associated with this
* menu item,
* @return the menu shortcut associated with this menu item,
- * or <code>null</code> if none has been specified.
+ * or {@code null} if none has been specified.
* @see java.awt.MenuItem#setShortcut
* @since 1.1
*/
public MenuShortcut getShortcut() {
return shortcut;
}
/**
- * Set the <code>MenuShortcut</code> object associated with this
+ * Set the {@code MenuShortcut} object associated with this
* menu item. If a menu shortcut is already associated with
* this menu item, it is replaced.
* @param s the menu shortcut to associate
* with this menu item.
* @see java.awt.MenuItem#getShortcut
@@ -356,11 +356,11 @@
peer.setLabel(label);
}
}
/**
- * Delete any <code>MenuShortcut</code> object associated
+ * Delete any {@code MenuShortcut} object associated
* with this menu item.
* @since 1.1
*/
public void deleteShortcut() {
shortcut = null;
@@ -452,12 +452,12 @@
* 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>
+ * to be invoked by subclasses of {@code MenuItem} which desire to
+ * have the specified event types delivered to {@code processEvent}
* regardless of whether a listener is registered.
*
* @param eventsToEnable the event mask defining the event types
* @see java.awt.MenuItem#processEvent
* @see java.awt.MenuItem#disableEvents
@@ -560,11 +560,11 @@
/**
* Returns an array of all the action listeners
* registered on this menu item.
*
- * @return all of this menu item's <code>ActionListener</code>s
+ * @return all of this menu item's {@code ActionListener}s
* or an empty array if no action
* listeners are currently registered
*
* @see #addActionListener
* @see #removeActionListener
@@ -577,37 +577,37 @@
}
/**
* Returns an array of all the objects currently registered
* as <code><em>Foo</em>Listener</code>s
- * upon this <code>MenuItem</code>.
+ * upon this {@code MenuItem}.
* <code><em>Foo</em>Listener</code>s are registered using the
* <code>add<em>Foo</em>Listener</code> method.
*
* <p>
- * You can specify the <code>listenerType</code> argument
+ * You can specify the {@code listenerType} argument
* with a class literal, such as
* <code><em>Foo</em>Listener.class</code>.
* For example, you can query a
- * <code>MenuItem</code> <code>m</code>
+ * {@code MenuItem m}
* for its action listeners with the following code:
*
* <pre>ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));</pre>
*
* If no such listeners exist, this method returns an empty array.
*
* @param <T> the type of the listeners
* @param listenerType the type of listeners requested; this parameter
* should specify an interface that descends from
- * <code>java.util.EventListener</code>
+ * {@code java.util.EventListener}
* @return an array of all objects registered as
* <code><em>Foo</em>Listener</code>s on this menu item,
* or an empty array if no such
* listeners have been added
- * @exception ClassCastException if <code>listenerType</code>
+ * @exception ClassCastException if {@code listenerType}
* doesn't specify a class or interface that implements
- * <code>java.util.EventListener</code>
+ * {@code java.util.EventListener}
*
* @see #getActionListeners
* @since 1.3
*/
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
@@ -618,16 +618,16 @@
return AWTEventMulticaster.getListeners(l, listenerType);
}
/**
* 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>.
+ * instance of {@code ActionEvent}, it invokes
+ * {@code processActionEvent}, another method
+ * defined by {@code MenuItem}.
* <p>
* Currently, menu items only support action events.
- * <p>Note that if the event parameter is <code>null</code>
+ * <p>Note that if the event parameter is {@code null}
* the behavior is unspecified and may result in an
* exception.
*
* @param e the event
* @see java.awt.MenuItem#processActionEvent
@@ -652,20 +652,20 @@
}
/**
* Processes action events occurring on this menu item,
* by dispatching them to any registered
- * <code>ActionListener</code> objects.
+ * {@code ActionListener} objects.
* This method is not called unless action events are
* enabled for this component. Action events are enabled
* when one of the following occurs:
* <ul>
- * <li>An <code>ActionListener</code> object is registered
- * via <code>addActionListener</code>.
- * <li>Action events are enabled via <code>enableEvents</code>.
+ * <li>An {@code ActionListener} object is registered
+ * via {@code addActionListener}.
+ * <li>Action events are enabled via {@code enableEvents}.
* </ul>
- * <p>Note that if the event parameter is <code>null</code>
+ * <p>Note that if the event parameter is {@code null}
* the behavior is unspecified and may result in an
* exception.
*
* @param e the action event
* @see java.awt.event.ActionEvent
@@ -679,15 +679,15 @@
listener.actionPerformed(e);
}
}
/**
- * Returns a string representing the state of this <code>MenuItem</code>.
+ * Returns a string representing the state of this {@code MenuItem}.
* This method is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not be
- * <code>null</code>.
+ * {@code null}.
*
* @return the parameter string of this menu item
*/
public String paramString() {
String str = ",label=" + label;
@@ -708,21 +708,21 @@
*/
private int menuItemSerializedDataVersion = 1;
/**
* Writes default serializable fields to stream. Writes
- * a list of serializable <code>ActionListeners</code>
+ * a list of serializable {@code ActionListeners}
* as optional data. The non-serializable listeners are
* detected and no attempt is made to serialize them.
*
- * @param s the <code>ObjectOutputStream</code> to write
- * @serialData <code>null</code> terminated sequence of 0
- * or more pairs; the pair consists of a <code>String</code>
- * and an <code>Object</code>; the <code>String</code>
+ * @param s the {@code ObjectOutputStream} to write
+ * @serialData {@code null} terminated sequence of 0
+ * or more pairs; the pair consists of a {@code String}
+ * and an {@code Object}; the {@code String}
* indicates the type of object and is one of the following:
- * <code>actionListenerK</code> indicating an
- * <code>ActionListener</code> object
+ * {@code actionListenerK} indicating an
+ * {@code ActionListener} object
*
* @see AWTEventMulticaster#save(ObjectOutputStream, String, EventListener)
* @see #readObject(ObjectInputStream)
*/
private void writeObject(ObjectOutputStream s)
@@ -733,19 +733,19 @@
AWTEventMulticaster.save(s, actionListenerK, actionListener);
s.writeObject(null);
}
/**
- * Reads the <code>ObjectInputStream</code> and if it
- * isn't <code>null</code> adds a listener to receive
- * action events fired by the <code>Menu</code> Item.
+ * Reads the {@code ObjectInputStream} and if it
+ * isn't {@code null} adds a listener to receive
+ * action events fired by the {@code Menu} Item.
* Unrecognized keys or values will be ignored.
*
- * @param s the <code>ObjectInputStream</code> to read
+ * @param s the {@code ObjectInputStream} to read
* @exception HeadlessException if
- * <code>GraphicsEnvironment.isHeadless</code> returns
- * <code>true</code>
+ * {@code GraphicsEnvironment.isHeadless} returns
+ * {@code true}
* @see #removeActionListener(ActionListener)
* @see #addActionListener(ActionListener)
* @see #writeObject(ObjectOutputStream)
*/
private void readObject(ObjectInputStream s)
@@ -798,11 +798,11 @@
* accessibility. This class is not meant to be used directly by
* application developers, but is instead meant only to be
* subclassed by menu component developers.
* <p>
* This class implements accessibility support for the
- * <code>MenuItem</code> class. It provides an implementation of the
+ * {@code MenuItem} class. It provides an implementation of the
* Java Accessibility API appropriate to menu item user-interface elements.
* @since 1.3
*/
protected class AccessibleAWTMenuItem extends AccessibleAWTMenuComponent
implements AccessibleAction, AccessibleValue
< prev index next >