src/java.desktop/share/classes/javax/swing/JMenuBar.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 20,50 ****
*
* 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.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
--- 20,45 ----
*
* 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.Graphics;
import java.awt.Insets;
import java.awt.event.*;
+ import java.beans.JavaBean;
+ import java.beans.BeanProperty;
import java.beans.Transient;
import java.util.Vector;
import java.io.Serializable;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;
import javax.swing.plaf.*;
import javax.accessibility.*;
/**
* An implementation of a menu bar. You add <code>JMenu</code> objects to the
*** 76,97 ****
* 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
*/
@SuppressWarnings("serial")
public class JMenuBar extends JComponent implements Accessible,MenuElement
{
/**
* @see #getUIClassID
--- 71,91 ----
* 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.
*
* @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,150 ****
/**
* Sets the L&F object that renders this component.
*
* @param ui the new MenuBarUI L&F object
* @see UIDefaults#getUI
- * @beaninfo
- * bound: true
- * hidden: true
- * attribute: visualUpdate true
- * description: The UI object that implements the Component's LookAndFeel.
*/
public void setUI(MenuBarUI ui) {
super.setUI(ui);
}
/**
--- 129,141 ----
/**
* Sets the L&F object that renders this component.
*
* @param ui the new MenuBarUI L&F object
* @see UIDefaults#getUI
*/
+ @BeanProperty(hidden = true, visualUpdate = true, description
+ = "The UI object that implements the Component's LookAndFeel.")
public void setUI(MenuBarUI ui) {
super.setUI(ui);
}
/**
*** 162,171 ****
--- 153,163 ----
*
* @return the string "MenuBarUI"
* @see JComponent#getUIClassID
* @see UIDefaults#getUI
*/
+ @BeanProperty(bound = false)
public String getUIClassID() {
return uiClassID;
}
*** 182,195 ****
/**
* 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.
*/
public void setSelectionModel(SingleSelectionModel model) {
SingleSelectionModel oldValue = selectionModel;
this.selectionModel = model;
firePropertyChange("selectionModel", oldValue, selectionModel);
}
--- 174,185 ----
/**
* Sets the model object to handle single selections.
*
* @param model the <code>SingleSelectionModel</code> to use
* @see SingleSelectionModel
*/
+ @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,234 ****
--- 215,225 ----
/**
* 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,311 ****
--- 293,303 ----
/**
* 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,335 ****
* 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.
*/
public void setBorderPainted(boolean b) {
boolean oldValue = paintBorder;
paintBorder = b;
firePropertyChange("borderPainted", oldValue, paintBorder);
if (b != oldValue) {
--- 313,325 ----
* 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
*/
+ @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,371 ****
* 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
*/
public void setMargin(Insets m) {
Insets old = margin;
this.margin = m;
firePropertyChange("margin", old, m);
if (old == null || !old.equals(m)) {
--- 347,359 ----
* 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
*/
+ @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,430 ****
--- 409,419 ----
* 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,494 ****
--- 474,484 ----
* 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;