< prev index next >
src/java.desktop/share/classes/javax/swing/JMenuItem.java
Print this page
@@ -43,18 +43,18 @@
import javax.accessibility.*;
/**
* An implementation of an item in a menu. A menu item is essentially a button
* sitting in a list. When the user selects the "button", the action
- * associated with the menu item is performed. A <code>JMenuItem</code>
- * contained in a <code>JPopupMenu</code> performs exactly that function.
+ * associated with the menu item is performed. A {@code JMenuItem}
+ * contained in a {@code JPopupMenu} performs exactly that function.
* <p>
* Menu items can be configured, and to some degree controlled, by
* <code><a href="Action.html">Action</a></code>s. Using an
- * <code>Action</code> with a menu item has many benefits beyond directly
+ * {@code Action} with a menu item has many benefits beyond directly
* configuring a menu item. Refer to <a href="Action.html#buttonActions">
- * Swing Components Supporting <code>Action</code></a> for more
+ * Swing Components Supporting {@code Action}</a> for more
* details, and you can find more information in <a
* href="http://docs.oracle.com/javase/tutorial/uiswing/misc/action.html">How
* to Use Actions</a>, a section in <em>The Java Tutorial</em>.
* <p>
* For further documentation and for examples, see
@@ -71,11 +71,11 @@
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
- * has been added to the <code>java.beans</code> package.
+ * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*
* @beaninfo
* attribute: isContainer false
* description: An item which can be selected in a menu.
@@ -103,64 +103,64 @@
private static final boolean DEBUG = false; // show bad params, misc.
private boolean isMouseDragged = false;
/**
- * Creates a <code>JMenuItem</code> with no set text or icon.
+ * Creates a {@code JMenuItem} with no set text or icon.
*/
public JMenuItem() {
this(null, (Icon)null);
}
/**
- * Creates a <code>JMenuItem</code> with the specified icon.
+ * Creates a {@code JMenuItem} with the specified icon.
*
- * @param icon the icon of the <code>JMenuItem</code>
+ * @param icon the icon of the {@code JMenuItem}
*/
public JMenuItem(Icon icon) {
this(null, icon);
}
/**
- * Creates a <code>JMenuItem</code> with the specified text.
+ * Creates a {@code JMenuItem} with the specified text.
*
- * @param text the text of the <code>JMenuItem</code>
+ * @param text the text of the {@code JMenuItem}
*/
public JMenuItem(String text) {
this(text, (Icon)null);
}
/**
* Creates a menu item whose properties are taken from the
- * specified <code>Action</code>.
+ * specified {@code Action}.
*
- * @param a the action of the <code>JMenuItem</code>
+ * @param a the action of the {@code JMenuItem}
* @since 1.3
*/
public JMenuItem(Action a) {
this();
setAction(a);
}
/**
- * Creates a <code>JMenuItem</code> with the specified text and icon.
+ * Creates a {@code JMenuItem} with the specified text and icon.
*
- * @param text the text of the <code>JMenuItem</code>
- * @param icon the icon of the <code>JMenuItem</code>
+ * @param text the text of the {@code JMenuItem}
+ * @param icon the icon of the {@code JMenuItem}
*/
public JMenuItem(String text, Icon icon) {
setModel(new DefaultButtonModel());
init(text, icon);
initFocusability();
}
/**
- * Creates a <code>JMenuItem</code> with the specified text and
+ * Creates a {@code JMenuItem} with the specified text and
* keyboard mnemonic.
*
- * @param text the text of the <code>JMenuItem</code>
- * @param mnemonic the keyboard mnemonic for the <code>JMenuItem</code>
+ * @param text the text of the {@code JMenuItem}
+ * @param mnemonic the keyboard mnemonic for the {@code JMenuItem}
*/
public JMenuItem(String text, int mnemonic) {
setModel(new DefaultButtonModel());
init(text, null);
setMnemonic(mnemonic);
@@ -176,12 +176,12 @@
((DefaultButtonModel)newModel).setMenuItem(true);
}
}
/**
- * Inititalizes the focusability of the <code>JMenuItem</code>.
- * <code>JMenuItem</code>'s are focusable, but subclasses may
+ * Inititalizes the focusability of the {@code JMenuItem}.
+ * {@code JMenuItem}'s are focusable, but subclasses may
* want to be, this provides them the opportunity to override this
* and invoke something else, or nothing at all. Refer to
* {@link javax.swing.JMenu#initFocusability} for the motivation of
* this.
*/
@@ -190,12 +190,12 @@
}
/**
* Initializes the menu item with the specified text and icon.
*
- * @param text the text of the <code>JMenuItem</code>
- * @param icon the icon of the <code>JMenuItem</code>
+ * @param text the text of the {@code JMenuItem}
+ * @param icon the icon of the {@code JMenuItem}
*/
protected void init(String text, Icon icon) {
if(text != null) {
setText(text);
}
@@ -228,11 +228,11 @@
/**
* Sets the look and feel object that renders this component.
*
- * @param ui the <code>JMenuItemUI</code> L&F object
+ * @param ui the {@code JMenuItemUI} L&F object
* @see UIDefaults#getUI
* @beaninfo
* bound: true
* hidden: true
* attribute: visualUpdate true
@@ -313,11 +313,11 @@
super.setEnabled(b);
}
/**
- * Returns true since <code>Menu</code>s, by definition,
+ * Returns true since {@code Menu}s, by definition,
* should always be on top of all other windows. If the menu is
* in an internal frame false is returned due to the rollover effect
* for windows laf where the menu is not always on top.
*/
// package private
@@ -340,11 +340,11 @@
* action listeners without navigating the menu hierarchy. It is the
* UI's responsibility to install the correct action. Note that
* when the keyboard accelerator is typed, it will work whether or
* not the menu is currently displayed.
*
- * @param keyStroke the <code>KeyStroke</code> which will
+ * @param keyStroke the {@code KeyStroke} which will
* serve as an accelerator
* @beaninfo
* description: The keystroke combination which will invoke the
* JMenuItem's actionlisteners without navigating the
* menu hierarchy
@@ -358,13 +358,13 @@
revalidate();
firePropertyChange("accelerator", oldAccelerator, accelerator);
}
/**
- * Returns the <code>KeyStroke</code> which serves as an accelerator
+ * Returns the {@code KeyStroke} which serves as an accelerator
* for the menu item.
- * @return a <code>KeyStroke</code> object identifying the
+ * @return a {@code KeyStroke} object identifying the
* accelerator key
*/
public KeyStroke getAccelerator() {
return this.accelerator;
}
@@ -413,20 +413,20 @@
}
}
/**
* Processes a mouse event forwarded from the
- * <code>MenuSelectionManager</code> and changes the menu
+ * {@code MenuSelectionManager} and changes the menu
* selection, if necessary, by using the
- * <code>MenuSelectionManager</code>'s API.
+ * {@code MenuSelectionManager}'s API.
* <p>
* Note: you do not have to forward the event to sub-components.
- * This is done automatically by the <code>MenuSelectionManager</code>.
+ * This is done automatically by the {@code MenuSelectionManager}.
*
- * @param e a <code>MouseEvent</code>
- * @param path the <code>MenuElement</code> path array
- * @param manager the <code>MenuSelectionManager</code>
+ * @param e a {@code MouseEvent}
+ * @param path the {@code MenuElement} path array
+ * @param manager the {@code MenuSelectionManager}
*/
public void processMouseEvent(MouseEvent e,MenuElement path[],MenuSelectionManager manager) {
processMenuDragMouseEvent(
new MenuDragMouseEvent(e.getComponent(), e.getID(),
e.getWhen(),
@@ -437,19 +437,19 @@
}
/**
* Processes a key event forwarded from the
- * <code>MenuSelectionManager</code> and changes the menu selection,
- * if necessary, by using <code>MenuSelectionManager</code>'s API.
+ * {@code MenuSelectionManager} and changes the menu selection,
+ * if necessary, by using {@code MenuSelectionManager}'s API.
* <p>
* Note: you do not have to forward the event to sub-components.
- * This is done automatically by the <code>MenuSelectionManager</code>.
+ * This is done automatically by the {@code MenuSelectionManager}.
*
- * @param e a <code>KeyEvent</code>
- * @param path the <code>MenuElement</code> path array
- * @param manager the <code>MenuSelectionManager</code>
+ * @param e a {@code KeyEvent}
+ * @param path the {@code MenuElement} path array
+ * @param manager the {@code MenuSelectionManager}
*/
public void processKeyEvent(KeyEvent e,MenuElement path[],MenuSelectionManager manager) {
if (DEBUG) {
System.out.println("in JMenuItem.processKeyEvent/3 for " + getText() +
" " + KeyStroke.getKeyStrokeForEvent(e));
@@ -468,11 +468,11 @@
/**
* Handles mouse drag in a menu.
*
- * @param e a <code>MenuDragMouseEvent</code> object
+ * @param e a {@code MenuDragMouseEvent} object
*/
public void processMenuDragMouseEvent(MenuDragMouseEvent e) {
switch (e.getID()) {
case MouseEvent.MOUSE_ENTERED:
isMouseDragged = false; fireMenuDragMouseEntered(e); break;
@@ -488,11 +488,11 @@
}
/**
* Handles a keystroke in a menu.
*
- * @param e a <code>MenuKeyEvent</code> object
+ * @param e a {@code MenuKeyEvent} object
*/
public void processMenuKeyEvent(MenuKeyEvent e) {
if (DEBUG) {
System.out.println("in JMenuItem.processMenuKeyEvent for " + getText()+
" " + KeyStroke.getKeyStrokeForEvent(e));
@@ -511,11 +511,11 @@
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
- * @param event a <code>MenuMouseDragEvent</code>
+ * @param event a {@code MenuMouseDragEvent}
* @see EventListenerList
*/
protected void fireMenuDragMouseEntered(MenuDragMouseEvent event) {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
@@ -531,11 +531,11 @@
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
- * @param event a <code>MenuDragMouseEvent</code>
+ * @param event a {@code MenuDragMouseEvent}
* @see EventListenerList
*/
protected void fireMenuDragMouseExited(MenuDragMouseEvent event) {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
@@ -551,11 +551,11 @@
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
- * @param event a <code>MenuDragMouseEvent</code>
+ * @param event a {@code MenuDragMouseEvent}
* @see EventListenerList
*/
protected void fireMenuDragMouseDragged(MenuDragMouseEvent event) {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
@@ -571,11 +571,11 @@
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
- * @param event a <code>MenuDragMouseEvent</code>
+ * @param event a {@code MenuDragMouseEvent}
* @see EventListenerList
*/
protected void fireMenuDragMouseReleased(MenuDragMouseEvent event) {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
@@ -591,11 +591,11 @@
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
- * @param event a <code>MenuKeyEvent</code>
+ * @param event a {@code MenuKeyEvent}
* @see EventListenerList
*/
protected void fireMenuKeyPressed(MenuKeyEvent event) {
if (DEBUG) {
System.out.println("in JMenuItem.fireMenuKeyPressed for " + getText()+
@@ -615,11 +615,11 @@
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
- * @param event a <code>MenuKeyEvent</code>
+ * @param event a {@code MenuKeyEvent}
* @see EventListenerList
*/
protected void fireMenuKeyReleased(MenuKeyEvent event) {
if (DEBUG) {
System.out.println("in JMenuItem.fireMenuKeyReleased for " + getText()+
@@ -639,11 +639,11 @@
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
- * @param event a <code>MenuKeyEvent</code>
+ * @param event a {@code MenuKeyEvent}
* @see EventListenerList
*/
protected void fireMenuKeyTyped(MenuKeyEvent event) {
if (DEBUG) {
System.out.println("in JMenuItem.fireMenuKeyTyped for " + getText()+
@@ -660,12 +660,12 @@
}
}
}
/**
- * Called by the <code>MenuSelectionManager</code> when the
- * <code>MenuElement</code> is selected or unselected.
+ * Called by the {@code MenuSelectionManager} when the
+ * {@code MenuElement} is selected or unselected.
*
* @param isIncluded true if this menu item is on the part of the menu
* path that changed, false if this menu is part of the
* a menu path that changed, but this particular part of
* that path is still the same
@@ -677,80 +677,80 @@
/**
* This method returns an array containing the sub-menu
* components for this menu component.
*
- * @return an array of <code>MenuElement</code>s
+ * @return an array of {@code MenuElement}s
*/
public MenuElement[] getSubElements() {
return new MenuElement[0];
}
/**
- * Returns the <code>java.awt.Component</code> used to paint
+ * Returns the {@code java.awt.Component} used to paint
* this object. The returned component will be used to convert
* events and detect if an event is inside a menu component.
*
- * @return the <code>Component</code> that paints this menu item
+ * @return the {@code Component} that paints this menu item
*/
public Component getComponent() {
return this;
}
/**
- * Adds a <code>MenuDragMouseListener</code> to the menu item.
+ * Adds a {@code MenuDragMouseListener} to the menu item.
*
- * @param l the <code>MenuDragMouseListener</code> to be added
+ * @param l the {@code MenuDragMouseListener} to be added
*/
public void addMenuDragMouseListener(MenuDragMouseListener l) {
listenerList.add(MenuDragMouseListener.class, l);
}
/**
- * Removes a <code>MenuDragMouseListener</code> from the menu item.
+ * Removes a {@code MenuDragMouseListener} from the menu item.
*
- * @param l the <code>MenuDragMouseListener</code> to be removed
+ * @param l the {@code MenuDragMouseListener} to be removed
*/
public void removeMenuDragMouseListener(MenuDragMouseListener l) {
listenerList.remove(MenuDragMouseListener.class, l);
}
/**
- * Returns an array of all the <code>MenuDragMouseListener</code>s added
+ * Returns an array of all the {@code MenuDragMouseListener}s added
* to this JMenuItem with addMenuDragMouseListener().
*
- * @return all of the <code>MenuDragMouseListener</code>s added or an empty
+ * @return all of the {@code MenuDragMouseListener}s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public MenuDragMouseListener[] getMenuDragMouseListeners() {
return listenerList.getListeners(MenuDragMouseListener.class);
}
/**
- * Adds a <code>MenuKeyListener</code> to the menu item.
+ * Adds a {@code MenuKeyListener} to the menu item.
*
- * @param l the <code>MenuKeyListener</code> to be added
+ * @param l the {@code MenuKeyListener} to be added
*/
public void addMenuKeyListener(MenuKeyListener l) {
listenerList.add(MenuKeyListener.class, l);
}
/**
- * Removes a <code>MenuKeyListener</code> from the menu item.
+ * Removes a {@code MenuKeyListener} from the menu item.
*
- * @param l the <code>MenuKeyListener</code> to be removed
+ * @param l the {@code MenuKeyListener} to be removed
*/
public void removeMenuKeyListener(MenuKeyListener l) {
listenerList.remove(MenuKeyListener.class, l);
}
/**
- * Returns an array of all the <code>MenuKeyListener</code>s added
+ * Returns an array of all the {@code MenuKeyListener}s added
* to this JMenuItem with addMenuKeyListener().
*
- * @return all of the <code>MenuKeyListener</code>s added or an empty
+ * @return all of the {@code MenuKeyListener}s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public MenuKeyListener[] getMenuKeyListeners() {
return listenerList.getListeners(MenuKeyListener.class);
@@ -780,35 +780,35 @@
}
}
/**
- * Returns a string representation of this <code>JMenuItem</code>.
+ * Returns a string representation of this {@code JMenuItem}.
* 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>.
+ * be {@code null}.
*
- * @return a string representation of this <code>JMenuItem</code>
+ * @return a string representation of this {@code JMenuItem}
*/
protected String paramString() {
return super.paramString();
}
/////////////////
// Accessibility support
////////////////
/**
- * Returns the <code>AccessibleContext</code> associated with this
- * <code>JMenuItem</code>. For <code>JMenuItem</code>s,
- * the <code>AccessibleContext</code> takes the form of an
- * <code>AccessibleJMenuItem</code>.
+ * Returns the {@code AccessibleContext} associated with this
+ * {@code JMenuItem}. For {@code JMenuItem}s,
+ * the {@code AccessibleContext} takes the form of an
+ * {@code AccessibleJMenuItem}.
* A new AccessibleJMenuItme instance is created if necessary.
*
- * @return an <code>AccessibleJMenuItem</code> that serves as the
- * <code>AccessibleContext</code> of this <code>JMenuItem</code>
+ * @return an {@code AccessibleJMenuItem} that serves as the
+ * {@code AccessibleContext} of this {@code JMenuItem}
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJMenuItem();
}
@@ -816,21 +816,21 @@
}
/**
* This class implements accessibility support for the
- * <code>JMenuItem</code> class. It provides an implementation of the
+ * {@code JMenuItem} class. It provides an implementation of the
* Java Accessibility API appropriate to menu item user-interface
* elements.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
- * has been added to the <code>java.beans</code> package.
+ * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*/
@SuppressWarnings("serial")
protected class AccessibleJMenuItem extends AccessibleAbstractButton implements ChangeListener {
< prev index next >