jdk/src/share/classes/javax/swing/JMenuItem.java

Print this page

        

@@ -22,25 +22,22 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 package javax.swing;
 
-import java.util.EventListener;
 import java.awt.*;
 import java.awt.event.*;
-import java.awt.image.*;
 
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
+import java.beans.JavaBean;
+import java.beans.BeanProperty;
 
 import java.io.Serializable;
 import java.io.ObjectOutputStream;
 import java.io.ObjectInputStream;
 import java.io.IOException;
 
 import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
 import javax.swing.event.*;
 import javax.accessibility.*;
 
 /**
  * An implementation of an item in a menu. A menu item is essentially a button

@@ -74,22 +71,20 @@
  * 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.
  * Please see {@link java.beans.XMLEncoder}.
  *
- * @beaninfo
- *   attribute: isContainer false
- * description: An item which can be selected in a menu.
- *
  * @author Georges Saab
  * @author David Karlton
  * @see JPopupMenu
  * @see JMenu
  * @see JCheckBoxMenuItem
  * @see JRadioButtonMenuItem
  * @since 1.2
  */
+@JavaBean(defaultProperty = "UIClassID", description = "An item which can be selected in a menu.")
+@SwingContainer(false)
 @SuppressWarnings("serial")
 public class JMenuItem extends AbstractButton implements Accessible,MenuElement  {
 
     /**
      * @see #getUIClassID

@@ -230,16 +225,13 @@
     /**
      * Sets the look and feel object that renders this component.
      *
      * @param ui  the <code>JMenuItemUI</code> L&amp;F object
      * @see UIDefaults#getUI
-     * @beaninfo
-     *        bound: true
-     *       hidden: true
-     *    attribute: visualUpdate true
-     *  description: The UI object that implements the Component's LookAndFeel.
      */
+    @BeanProperty(hidden = true, visualUpdate = true, description
+            = "The UI object that implements the LookAndFeel.")
     public void setUI(MenuItemUI ui) {
         super.setUI(ui);
     }
 
     /**

@@ -258,10 +250,11 @@
      *
      * @return the string "MenuItemUI"
      * @see JComponent#getUIClassID
      * @see UIDefaults#getUI
      */
+    @BeanProperty(bound = false)
     public String getUIClassID() {
         return uiClassID;
     }
 
 

@@ -270,14 +263,13 @@
      * released while it is over this item, the menu's action event
      * will fire. If the mouse button is released elsewhere, the
      * event will not fire and the menu item will be disarmed.
      *
      * @param b true to arm the menu item so it can be selected
-     * @beaninfo
-     *    description: Mouse release will fire an action event
-     *         hidden: true
      */
+    @BeanProperty(bound = false, hidden = true, description
+            = "Mouse release will fire an action event")
     public void setArmed(boolean b) {
         ButtonModel model = getModel();
 
         boolean oldValue = model.isArmed();
         if(model.isArmed() != b) {

@@ -298,15 +290,13 @@
 
     /**
      * Enables or disables the menu item.
      *
      * @param b  true to enable the item
-     * @beaninfo
-     *    description: Does the component react to user interaction
-     *          bound: true
-     *      preferred: true
      */
+    @BeanProperty(preferred = true, description
+            = "The enabled state of the component.")
     public void setEnabled(boolean b) {
         // Make sure we aren't armed!
         if (!b && !UIManager.getBoolean("MenuItem.disabledAreNavigable")) {
             setArmed(false);
         }

@@ -342,17 +332,13 @@
      * 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
      *          serve as an accelerator
-     * @beaninfo
-     *     description: The keystroke combination which will invoke the
-     *                  JMenuItem's actionlisteners without navigating the
-     *                  menu hierarchy
-     *           bound: true
-     *       preferred: true
      */
+    @BeanProperty(preferred = true, description
+            = "The keystroke combination which will invoke the JMenuItem's actionlisteners without navigating the menu hierarchy")
     public void setAccelerator(KeyStroke keyStroke) {
         KeyStroke oldAccelerator = accelerator;
         this.accelerator = keyStroke;
         repaint();
         revalidate();

@@ -679,10 +665,11 @@
      * This method returns an array containing the sub-menu
      * components for this menu component.
      *
      * @return an array of <code>MenuElement</code>s
      */
+    @BeanProperty(bound = false)
     public MenuElement[] getSubElements() {
         return new MenuElement[0];
     }
 
     /**

@@ -720,10 +707,11 @@
      *
      * @return all of the <code>MenuDragMouseListener</code>s added or an empty
      *         array if no listeners have been added
      * @since 1.4
      */
+    @BeanProperty(bound = false)
     public MenuDragMouseListener[] getMenuDragMouseListeners() {
         return listenerList.getListeners(MenuDragMouseListener.class);
     }
 
     /**

@@ -750,10 +738,11 @@
      *
      * @return all of the <code>MenuKeyListener</code>s added or an empty
      *         array if no listeners have been added
      * @since 1.4
      */
+    @BeanProperty(bound = false)
     public MenuKeyListener[] getMenuKeyListeners() {
         return listenerList.getListeners(MenuKeyListener.class);
     }
 
     /**

@@ -806,10 +795,11 @@
      * 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>
      */
+    @BeanProperty(bound = false)
     public AccessibleContext getAccessibleContext() {
         if (accessibleContext == null) {
             accessibleContext = new AccessibleJMenuItem();
         }
         return accessibleContext;