src/java.desktop/share/classes/javax/swing/JComboBox.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -22,10 +22,12 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing;
+import java.beans.JavaBean;
+import java.beans.BeanProperty;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.Transient;
import java.util.*;
@@ -69,18 +71,16 @@
* @see ComboBoxModel
* @see DefaultComboBoxModel
*
* @param <E> the type of the elements of this combo box
*
- * @beaninfo
- * attribute: isContainer false
- * description: A combination of a text field and a drop-down list.
- *
* @author Arnaud Weber
* @author Mark Davidson
* @since 1.2
*/
+@JavaBean(defaultProperty = "UI", description = "A combination of a text field and a drop-down list.")
+@SwingContainer(false)
@SuppressWarnings("serial") // Same-version serialization only
public class JComboBox<E> extends JComponent
implements ItemSelectable,ListDataListener,ActionListener, Accessible {
/**
* @see #getUIClassID
@@ -253,17 +253,13 @@
/**
* Sets the L&F object that renders this component.
*
* @param ui the <code>ComboBoxUI</code> L&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(ComboBoxUI ui) {
super.setUI(ui);
}
/**
@@ -286,10 +282,11 @@
*
* @return the string "ComboBoxUI"
* @see JComponent#getUIClassID
* @see UIDefaults#getUI
*/
+ @BeanProperty(bound = false)
public String getUIClassID() {
return uiClassID;
}
@@ -306,15 +303,13 @@
* Sets the data model that the <code>JComboBox</code> uses to obtain
* the list of items.
*
* @param aModel the <code>ComboBoxModel</code> that provides the
* displayed list of items
- *
- * @beaninfo
- * bound: true
- * description: Model that the combo box uses to get data to display.
*/
+ @BeanProperty(description
+ = "Model that the combo box uses to get data to display.")
public void setModel(ComboBoxModel<E> aModel) {
ComboBoxModel<E> oldModel = dataModel;
if (oldModel != null) {
oldModel.removeListDataListener(this);
}
@@ -361,16 +356,13 @@
* <p>
* See the article <a href="http://www.oracle.com/technetwork/articles/java/mixing-components-433992.html">Mixing Heavy and Light Components</a>
* This method fires a property changed event.
*
* @param aFlag if <code>true</code>, lightweight popups are desired
- *
- * @beaninfo
- * bound: true
- * expert: true
- * description: Set to <code>false</code> to require heavyweight popups.
*/
+ @BeanProperty(expert = true, description
+ = "Set to <code>false</code> to require heavyweight popups.")
public void setLightWeightPopupEnabled(boolean aFlag) {
boolean oldFlag = lightWeightPopupEnabled;
lightWeightPopupEnabled = aFlag;
firePropertyChange("lightWeightPopupEnabled", oldFlag, lightWeightPopupEnabled);
}
@@ -396,16 +388,13 @@
* displays the selected item in the field,
* but the selection cannot be modified.
*
* @param aFlag a boolean value, where true indicates that the
* field is editable
- *
- * @beaninfo
- * bound: true
- * preferred: true
- * description: If true, the user can type a new value in the combo box.
*/
+ @BeanProperty(preferred = true, description
+ = "If true, the user can type a new value in the combo box.")
public void setEditable(boolean aFlag) {
boolean oldFlag = isEditable;
isEditable = aFlag;
firePropertyChange( "editable", oldFlag, isEditable );
}
@@ -425,15 +414,13 @@
* If the number of objects in the model is greater than count,
* the combo box uses a scrollbar.
*
* @param count an integer specifying the maximum number of items to
* display in the list before using a scrollbar
- * @beaninfo
- * bound: true
- * preferred: true
- * description: The maximum number of rows the popup should have
*/
+ @BeanProperty(preferred = true, description
+ = "The maximum number of rows the popup should have")
public void setMaximumRowCount(int count) {
int oldCount = maximumRowCount;
maximumRowCount = count;
firePropertyChange( "maximumRowCount", oldCount, maximumRowCount );
}
@@ -463,15 +450,13 @@
* is called, passing the list object and an index of -1.
*
* @param aRenderer the <code>ListCellRenderer</code> that
* displays the selected item
* @see #setEditor
- * @beaninfo
- * bound: true
- * expert: true
- * description: The renderer that paints the item selected in the list.
*/
+ @BeanProperty(expert = true, description
+ = "The renderer that paints the item selected in the list.")
public void setRenderer(ListCellRenderer<? super E> aRenderer) {
ListCellRenderer<? super E> oldRenderer = renderer;
renderer = aRenderer;
firePropertyChange( "renderer", oldRenderer, renderer );
invalidate();
@@ -495,15 +480,13 @@
* the combo box uses the renderer to paint the selected item.
*
* @param anEditor the <code>ComboBoxEditor</code> that
* displays the selected item
* @see #setRenderer
- * @beaninfo
- * bound: true
- * expert: true
- * description: The editor that combo box uses to edit the current value
*/
+ @BeanProperty(expert = true, description
+ = "The editor that combo box uses to edit the current value")
public void setEditor(ComboBoxEditor anEditor) {
ComboBoxEditor oldEditor = editor;
if ( editor != null ) {
editor.removeActionListener(this);
@@ -551,14 +534,13 @@
* <code>ActionListener</code>s added to the combo box will be notified
* with an <code>ActionEvent</code> when this method is called.
*
* @param anObject the list object to select; use <code>null</code> to
clear the selection
- * @beaninfo
- * preferred: true
- * description: Sets the selected item in the JComboBox.
*/
+ @BeanProperty(bound = false, preferred = true, description
+ = "Sets the selected item in the JComboBox.")
public void setSelectedItem(Object anObject) {
Object oldSelection = selectedItemReminder;
Object objectToSelect = anObject;
if (oldSelection == null || !oldSelection.equals(anObject)) {
@@ -616,14 +598,13 @@
*
* @param anIndex an integer specifying the list item to select,
* where 0 specifies the first item in the list and -1 indicates no selection
* @exception IllegalArgumentException if <code>anIndex</code> < -1 or
* <code>anIndex</code> is greater than or equal to size
- * @beaninfo
- * preferred: true
- * description: The item at index is selected.
*/
+ @BeanProperty(bound = false, preferred = true, description
+ = "The item at index is selected.")
public void setSelectedIndex(int anIndex) {
int size = dataModel.getSize();
if ( anIndex == -1 ) {
setSelectedItem( null );
@@ -687,15 +668,13 @@
* relatively expensive.
*
* @param prototypeDisplayValue the prototype display value
* @see #getPrototypeDisplayValue
* @since 1.4
- * @beaninfo
- * bound: true
- * attribute: visualUpdate true
- * description: The display prototype value, used to compute display width and height.
*/
+ @BeanProperty(visualUpdate = true, description
+ = "The display prototype value, used to compute display width and height.")
public void setPrototypeDisplayValue(E prototypeDisplayValue) {
Object oldValue = this.prototypeDisplayValue;
this.prototypeDisplayValue = prototypeDisplayValue;
firePropertyChange("prototypeDisplayValue", oldValue, prototypeDisplayValue);
}
@@ -867,10 +846,11 @@
*
* @return all of the <code>ItemListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
+ @BeanProperty(bound = false)
public ItemListener[] getItemListeners() {
return listenerList.getListeners(ItemListener.class);
}
/**
@@ -905,10 +885,11 @@
*
* @return all of the <code>ActionListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
+ @BeanProperty(bound = false)
public ActionListener[] getActionListeners() {
return listenerList.getListeners(ActionListener.class);
}
/**
@@ -944,10 +925,11 @@
*
* @return all of the <code>PopupMenuListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
+ @BeanProperty(bound = false)
public PopupMenuListener[] getPopupMenuListeners() {
return listenerList.getListeners(PopupMenuListener.class);
}
/**
@@ -1072,15 +1054,13 @@
* @see Action
* @see #getAction
* @see #configurePropertiesFromAction
* @see #createActionPropertyChangeListener
* @see #actionPropertyChanged
- * @beaninfo
- * bound: true
- * attribute: visualUpdate true
- * description: the Action instance connected with this ActionEvent source
*/
+ @BeanProperty(visualUpdate = true, description
+ = "the Action instance connected with this ActionEvent source")
public void setAction(Action a) {
Action oldValue = getAction();
if (action==null || !action.equals(a)) {
action = a;
if (oldValue!=null) {
@@ -1303,10 +1283,11 @@
* <code>ItemSelectable</code>.
*
* @return an array of <code>Objects</code> containing one
* element -- the selected item
*/
+ @BeanProperty(bound = false)
public Object[] getSelectedObjects() {
Object selectedObject = getSelectedItem();
if ( selectedObject == null )
return new Object[0];
else {
@@ -1392,15 +1373,13 @@
* combo box is disabled, items cannot be selected and values
* cannot be typed into its field (if it is editable).
*
* @param b a boolean value, where true enables the component and
* false disables it
- * @beaninfo
- * bound: true
- * preferred: true
- * description: Whether the combo box is enabled.
*/
+ @BeanProperty(preferred = true, description
+ = "The enabled state of the component.")
public void setEnabled(boolean b) {
super.setEnabled(b);
firePropertyChange( "enabled", !isEnabled(), isEnabled() );
}
@@ -1456,14 +1435,13 @@
* Sets the object that translates a keyboard character into a list
* selection. Typically, the first selection with a matching first
* character becomes the selected item.
*
* @param aManager a key selection manager
- * @beaninfo
- * expert: true
- * description: The objects that changes the selection when a key is pressed.
*/
+ @BeanProperty(bound = false, expert = true, description
+ = "The objects that changes the selection when a key is pressed.")
public void setKeySelectionManager(KeySelectionManager aManager) {
keySelectionManager = aManager;
}
/**
@@ -1479,10 +1457,11 @@
/**
* Returns the number of items in the list.
*
* @return an integer equal to the number of items in the list
*/
+ @BeanProperty(bound = false)
public int getItemCount() {
return dataModel.getSize();
}
/**
@@ -1627,10 +1606,11 @@
* A new AccessibleJComboBox instance is created if necessary.
*
* @return an AccessibleJComboBox that serves as the
* AccessibleContext of this JComboBox
*/
+ @BeanProperty(bound = false)
public AccessibleContext getAccessibleContext() {
if ( accessibleContext == null ) {
accessibleContext = new AccessibleJComboBox();
}
return accessibleContext;
@@ -2129,15 +2109,13 @@
*
* @param s the new localized name of the object.
*
* @see #getAccessibleName
* @see #addPropertyChangeListener
- *
- * @beaninfo
- * preferred: true
- * description: Sets the accessible name for the component.
*/
+ @BeanProperty(preferred = true, description
+ = "Sets the accessible name for the component.")
public void setAccessibleName(String s) {
ac.setAccessibleName(s);
}
/**
@@ -2163,15 +2141,13 @@
*
* @param s the new localized description of the object
*
* @see #setAccessibleName
* @see #addPropertyChangeListener
- *
- * @beaninfo
- * preferred: true
- * description: Sets the accessible description for the component.
*/
+ @BeanProperty(preferred = true, description
+ = "Sets the accessible description for the component.")
public void setAccessibleDescription(String s) {
ac.setAccessibleDescription(s);
}
/**