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

Print this page

        

@@ -20,31 +20,26 @@
  *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package javax.swing;
 
 import java.awt.Component;
-import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.Insets;
-import java.awt.Point;
-import java.awt.Rectangle;
 import java.awt.event.*;
+import java.beans.JavaBean;
+import java.beans.BeanProperty;
 import java.beans.Transient;
 import java.util.Vector;
-import java.util.Enumeration;
 
 import java.io.Serializable;
 import java.io.ObjectOutputStream;
 import java.io.ObjectInputStream;
 import java.io.IOException;
 
-import javax.swing.event.*;
-import javax.swing.border.Border;
 import javax.swing.plaf.*;
 import javax.accessibility.*;
 
 /**
  * An implementation of a menu bar. You add <code>JMenu</code> objects to the

@@ -76,22 +71,21 @@
  * JMenuBar</code> which is added to a container together with other Swing
  * components, because the <code>focusTraversalKeysEnabled</code> property
  * of <code>JMenuBar</code> is set to <code>false</code>. To resolve this,
  * you should call the <code>JMenuBar.setFocusTraversalKeysEnabled(true)</code>
  * method.
- * @beaninfo
- *   attribute: isContainer true
- * description: A container for holding and displaying menus.
  *
  * @author Georges Saab
  * @author David Karlton
  * @author Arnaud Weber
  * @see JMenu
  * @see JPopupMenu
  * @see JMenuItem
  * @since 1.2
  */
+@JavaBean(defaultProperty = "UI", description = "A container for holding and displaying menus.")
+@SwingContainer
 @SuppressWarnings("serial")
 public class JMenuBar extends JComponent implements Accessible,MenuElement
 {
     /**
      * @see #getUIClassID

@@ -135,16 +129,13 @@
     /**
      * Sets the L&amp;F object that renders this component.
      *
      * @param ui the new MenuBarUI 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 Component's LookAndFeel.")
     public void setUI(MenuBarUI ui) {
         super.setUI(ui);
     }
 
     /**

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

@@ -182,14 +174,12 @@
     /**
      * Sets the model object to handle single selections.
      *
      * @param model the <code>SingleSelectionModel</code> to use
      * @see SingleSelectionModel
-     * @beaninfo
-     *       bound: true
-     * description: The selection model, recording which child is selected.
      */
+    @BeanProperty(description = "The selection model, recording which child is selected.")
     public void setSelectionModel(SingleSelectionModel model) {
         SingleSelectionModel oldValue = selectionModel;
         this.selectionModel = model;
         firePropertyChange("selectionModel", oldValue, selectionModel);
     }

@@ -225,10 +215,11 @@
     /**
      * Returns the number of items in the menu bar.
      *
      * @return the number of items in the menu bar
      */
+    @BeanProperty(bound = false)
     public int getMenuCount() {
         return getComponentCount();
     }
 
     /**

@@ -302,10 +293,11 @@
     /**
      * Returns true if the menu bar currently has a component selected.
      *
      * @return true if a selection has been made, else false
      */
+    @BeanProperty(bound = false)
     public boolean isSelected() {
         return selectionModel.isSelected();
     }
 
     /**

@@ -321,15 +313,13 @@
      * Sets whether the border should be painted.
      *
      * @param b if true and border property is not <code>null</code>,
      *          the border is painted.
      * @see #isBorderPainted
-     * @beaninfo
-     *        bound: true
-     *    attribute: visualUpdate true
-     *  description: Whether the border should be painted.
      */
+    @BeanProperty(visualUpdate = true, description
+            = "Whether the border should be painted.")
     public void setBorderPainted(boolean b) {
         boolean oldValue = paintBorder;
         paintBorder = b;
         firePropertyChange("borderPainted", oldValue, paintBorder);
         if (b != oldValue) {

@@ -357,15 +347,13 @@
      * its menus. Setting to <code>null</code> will cause the menubar to
      * use the default margins.
      *
      * @param m an Insets object containing the margin values
      * @see Insets
-     * @beaninfo
-     *        bound: true
-     *    attribute: visualUpdate true
-     *  description: The space between the menubar's border and its contents
      */
+    @BeanProperty(visualUpdate = true, description
+            = "The space between the menubar's border and its contents")
     public void setMargin(Insets m) {
         Insets old = margin;
         this.margin = m;
         firePropertyChange("margin", old, m);
         if (old == null || !old.equals(m)) {

@@ -421,10 +409,11 @@
      * This is the reason for implementing the <code>MenuElement</code>
      * interface -- so that the menu bar can be treated the same as
      * other menu elements.
      * @return an array of menu items in the menu bar.
      */
+    @BeanProperty(bound = false)
     public MenuElement[] getSubElements() {
         MenuElement result[];
         Vector<MenuElement> tmp = new Vector<MenuElement>();
         int c = getComponentCount();
         int i;

@@ -485,10 +474,11 @@
      * A new AccessibleJMenuBar instance is created if necessary.
      *
      * @return an AccessibleJMenuBar that serves as the
      *         AccessibleContext of this JMenuBar
      */
+    @BeanProperty(bound = false)
     public AccessibleContext getAccessibleContext() {
         if (accessibleContext == null) {
             accessibleContext = new AccessibleJMenuBar();
         }
         return accessibleContext;