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

Print this page

        

*** 22,31 **** --- 22,33 ---- * 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,86 **** * @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 */ @SuppressWarnings("serial") // Same-version serialization only public class JComboBox<E> extends JComponent implements ItemSelectable,ListDataListener,ActionListener, Accessible { /** * @see #getUIClassID --- 71,86 ---- * @see ComboBoxModel * @see DefaultComboBoxModel * * @param <E> the type of the elements of this combo box * * @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,269 **** /** * Sets the L&amp;F object that renders this component. * * @param ui the <code>ComboBoxUI</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. */ public void setUI(ComboBoxUI ui) { super.setUI(ui); } /** --- 253,265 ---- /** * Sets the L&amp;F object that renders this component. * * @param ui the <code>ComboBoxUI</code> L&amp;F object * @see UIDefaults#getUI */ + @BeanProperty(hidden = true, visualUpdate = true, description + = "The UI object that implements the Component's LookAndFeel.") public void setUI(ComboBoxUI ui) { super.setUI(ui); } /**
*** 286,295 **** --- 282,292 ---- * * @return the string "ComboBoxUI" * @see JComponent#getUIClassID * @see UIDefaults#getUI */ + @BeanProperty(bound = false) public String getUIClassID() { return uiClassID; }
*** 306,320 **** * 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. */ public void setModel(ComboBoxModel<E> aModel) { ComboBoxModel<E> oldModel = dataModel; if (oldModel != null) { oldModel.removeListDataListener(this); } --- 303,315 ---- * 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 */ + @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,376 **** * <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. */ public void setLightWeightPopupEnabled(boolean aFlag) { boolean oldFlag = lightWeightPopupEnabled; lightWeightPopupEnabled = aFlag; firePropertyChange("lightWeightPopupEnabled", oldFlag, lightWeightPopupEnabled); } --- 356,368 ---- * <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 */ + @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,411 **** * 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. */ public void setEditable(boolean aFlag) { boolean oldFlag = isEditable; isEditable = aFlag; firePropertyChange( "editable", oldFlag, isEditable ); } --- 388,400 ---- * 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 */ + @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,439 **** * 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 */ public void setMaximumRowCount(int count) { int oldCount = maximumRowCount; maximumRowCount = count; firePropertyChange( "maximumRowCount", oldCount, maximumRowCount ); } --- 414,426 ---- * 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 */ + @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,477 **** * 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. */ public void setRenderer(ListCellRenderer<? super E> aRenderer) { ListCellRenderer<? super E> oldRenderer = renderer; renderer = aRenderer; firePropertyChange( "renderer", oldRenderer, renderer ); invalidate(); --- 450,462 ---- * is called, passing the list object and an index of -1. * * @param aRenderer the <code>ListCellRenderer</code> that * displays the selected item * @see #setEditor */ + @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,509 **** * 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 */ public void setEditor(ComboBoxEditor anEditor) { ComboBoxEditor oldEditor = editor; if ( editor != null ) { editor.removeActionListener(this); --- 480,492 ---- * the combo box uses the renderer to paint the selected item. * * @param anEditor the <code>ComboBoxEditor</code> that * displays the selected item * @see #setRenderer */ + @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,564 **** * <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. */ public void setSelectedItem(Object anObject) { Object oldSelection = selectedItemReminder; Object objectToSelect = anObject; if (oldSelection == null || !oldSelection.equals(anObject)) { --- 534,546 ---- * <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 */ + @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)) {
*** 614,627 **** * * @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> &lt; -1 or * <code>anIndex</code> is greater than or equal to size - * @beaninfo - * preferred: true - * description: The item at index is selected. */ public void setSelectedIndex(int anIndex) { int size = dataModel.getSize(); if ( anIndex == -1 ) { setSelectedItem( null ); --- 596,608 ---- * * @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> &lt; -1 or * <code>anIndex</code> is greater than or equal to size */ + @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 );
*** 685,699 **** * 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. */ public void setPrototypeDisplayValue(E prototypeDisplayValue) { Object oldValue = this.prototypeDisplayValue; this.prototypeDisplayValue = prototypeDisplayValue; firePropertyChange("prototypeDisplayValue", oldValue, prototypeDisplayValue); } --- 666,678 ---- * relatively expensive. * * @param prototypeDisplayValue the prototype display value * @see #getPrototypeDisplayValue * @since 1.4 */ + @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); }
*** 865,874 **** --- 844,854 ---- * * @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); } /**
*** 903,912 **** --- 883,893 ---- * * @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); } /**
*** 942,951 **** --- 923,933 ---- * * @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); } /**
*** 1070,1084 **** * @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 */ public void setAction(Action a) { Action oldValue = getAction(); if (action==null || !action.equals(a)) { action = a; if (oldValue!=null) { --- 1052,1064 ---- * @see Action * @see #getAction * @see #configurePropertiesFromAction * @see #createActionPropertyChangeListener * @see #actionPropertyChanged */ + @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) {
*** 1301,1310 **** --- 1281,1291 ---- * <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 {
*** 1393,1407 **** * 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. */ public void setEnabled(boolean b) { super.setEnabled(b); firePropertyChange( "enabled", !isEnabled(), isEnabled() ); } --- 1374,1386 ---- * 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 */ + @BeanProperty(preferred = true, description + = "The enabled state of the component.") public void setEnabled(boolean b) { super.setEnabled(b); firePropertyChange( "enabled", !isEnabled(), isEnabled() ); }
*** 1457,1470 **** * 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. */ public void setKeySelectionManager(KeySelectionManager aManager) { keySelectionManager = aManager; } /** --- 1436,1448 ---- * 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 */ + @BeanProperty(bound = false, expert = true, description + = "The objects that changes the selection when a key is pressed.") public void setKeySelectionManager(KeySelectionManager aManager) { keySelectionManager = aManager; } /**
*** 1480,1489 **** --- 1458,1468 ---- /** * 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(); } /**
*** 1628,1637 **** --- 1607,1617 ---- * 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;
*** 2130,2144 **** * * @param s the new localized name of the object. * * @see #getAccessibleName * @see #addPropertyChangeListener - * - * @beaninfo - * preferred: true - * description: Sets the accessible name for the component. */ public void setAccessibleName(String s) { ac.setAccessibleName(s); } /** --- 2110,2122 ---- * * @param s the new localized name of the object. * * @see #getAccessibleName * @see #addPropertyChangeListener */ + @BeanProperty(preferred = true, description + = "Sets the accessible name for the component.") public void setAccessibleName(String s) { ac.setAccessibleName(s); } /**
*** 2164,2178 **** * * @param s the new localized description of the object * * @see #setAccessibleName * @see #addPropertyChangeListener - * - * @beaninfo - * preferred: true - * description: Sets the accessible description for the component. */ public void setAccessibleDescription(String s) { ac.setAccessibleDescription(s); } /** --- 2142,2154 ---- * * @param s the new localized description of the object * * @see #setAccessibleName * @see #addPropertyChangeListener */ + @BeanProperty(preferred = true, description + = "Sets the accessible description for the component.") public void setAccessibleDescription(String s) { ac.setAccessibleDescription(s); } /**