Warning
Swing is not thread safe. For more information see Swing's Threading Policy.
Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
See How to Use Combo Boxes in The Java Tutorial for further information.
ComboBoxModel, DefaultComboBoxModel
| Modifier and Type | Class and Description |
|---|---|
| protected class | JComboBox.
This class implements accessibility support for the
|
| private static class | |
| pack-priv static class | |
| public static interface | JComboBox.
The interface that defines a |
| Modifier and Type | Field and Description |
|---|---|
| private Action | |
| protected String | actionCommand
This protected field is implementation specific. |
| private PropertyChangeListener | |
| protected ComboBoxModel | dataModel
This protected field is implementation specific. |
| protected ComboBoxEditor | editor
This protected field is implementation specific. |
| private boolean | |
| protected boolean | isEditable
This protected field is implementation specific. |
| protected JComboBox. | keySelectionManager
This protected field is implementation specific. |
| protected boolean | lightWeightPopupEnabled
This protected field is implementation specific. |
| protected int | maximumRowCount
This protected field is implementation specific. |
| private E | |
| protected ListCellRenderer | renderer
This protected field is implementation specific. |
| protected Object | selectedItemReminder
This protected field is implementation specific. |
| private boolean | |
| private static final String | |
| private transient boolean |
| Access | Constructor and Description |
|---|---|
| public | JComboBox(ComboBoxModel<E>
the aModel)ComboBoxModel that provides the
displayed list of itemsCreates a |
| public | JComboBox(E[]
an array of objects to insert into the combo box items)Creates a |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | actionPerformed(ActionEvent e)
Implements java. This method is public as an implementation side effect. |
| protected void | actionPropertyChanged(Action
the action, String Action associated with this comboboxthe name of the property that changed propertyName)Updates the combobox's state in response to property changes in associated action. |
| public void | |
| public void | |
| public void | addItemListener(ItemListener
the aListener)ItemListener that is to be notifiedImplements java. Adds an |
| public void | addPopupMenuListener(PopupMenuListener
the l)PopupMenuListener to addAdds a |
| pack-priv void | |
| public void | configureEditor(ComboBoxEditor
the anEditor, Object ComboBoxEditor that displays
the list item in the
combo box field and allows it to be editedthe object to display and edit in the field anItem)Initializes the editor with the specified item. |
| protected void | configurePropertiesFromAction(Action
the a)Action from which to get the properties,
or nullSets the properties on this combobox to match those in the specified
|
| public void | contentsChanged(ListDataEvent e)
Implements javax. This method is public as an implementation side effect. |
| protected PropertyChangeListener | Returns: thePropertyChangeListenerthe combobox's action a)Creates and returns a |
| protected JComboBox. | Returns: theKeySelectionManager currently used by the listReturns an instance of the default key-selection manager. |
| protected void | fireActionEvent()
Notifies all listeners that have registered interest for notification on this event type. |
| protected void | fireItemStateChanged(ItemEvent
the event of interest e)Notifies all listeners that have registered interest for notification on this event type. |
| public void | firePopupMenuCanceled()
Notifies |
| public void | firePopupMenuWillBecomeInvisible()
Notifies |
| public void | firePopupMenuWillBecomeVisible()
Notifies |
| public AccessibleContext | Returns: an AccessibleJComboBox that serves as the AccessibleContext of this JComboBoxOverrides java. Implements javax. Gets the AccessibleContext associated with this JComboBox. |
| public Action | Returns: theAction for this ActionEvent
source; or nullReturns the currently set |
| public String | Returns: the string containing the "command" that is sent to action listeners.Returns the action command that is included in the event sent to action listeners. |
| public ActionListener[] | Returns: all of theActionListeners added or an empty
array if no listeners have been addedReturns an array of all the |
| public ComboBoxEditor | Returns: theComboBoxEditor that displays the selected itemReturns the editor used to paint and edit the selected item in the
|
| public E | Returns: the item at that list position; ornull if out of rangean integer indicating the list position, where the first
item starts at zero index)Returns the list item at the specified index. |
| public int | Returns: an integer equal to the number of items in the listReturns the number of items in the list. |
| public ItemListener[] | Returns: all of theItemListeners added or an empty
array if no listeners have been addedReturns an array of all the |
| public JComboBox. | Returns: theKeySelectionManager currently in useReturns the list's key-selection manager. |
| public int | Returns: an integer specifying the maximum number of items that are displayed in the list before using a scrollbarReturns the maximum number of items the combo box can display without a scrollbar |
| public ComboBoxModel | Returns: theComboBoxModel that provides the displayed
list of itemsReturns the data model currently used by the |
| public PopupMenuListener[] | Returns: all of thePopupMenuListeners added or an empty
array if no listeners have been addedReturns an array of all the |
| public E | Returns: the value of theprototypeDisplayValue propertyReturns the "prototypical display" value - an Object used for the calculation of the display height and width. |
| public ListCellRenderer | Returns: theListCellRenderer that displays
the selected item.Returns the renderer used to display the selected item in the
|
| public int | Returns: an integer specifying the currently selected list item, where 0 specifies the first item in the list; or -1 if no item is selected or if the currently selected item is not in the listReturns the first item in the list that matches the given item. |
| public Object | |
| public Object[] | Returns: an array ofObjects containing one
element -- the selected itemImplements java. Returns an array containing the selected item. |
| public ComboBoxUI | Returns: the ComboBoxUI object that renders this componentOverrides javax. Returns the L&F object that renders this component. |
| public String | Returns: the string "ComboBoxUI"Overrides javax. Returns the name of the L&F class that renders this component. |
| public void | |
| private void | |
| public void | insertItemAt(E
the item to add to the list item, int an integer specifying the position at which
to add the item index)Inserts an item into the item list at a given index. |
| protected void | installAncestorListener()
Registers ancestor listener so that it will receive
|
| public void | intervalAdded(ListDataEvent e)
Implements javax. This method is public as an implementation side effect. |
| public void | intervalRemoved(ListDataEvent e)
Implements javax. This method is public as an implementation side effect. |
| public boolean | Returns: true if theJComboBox is editable, else falseReturns true if the |
| public boolean | Returns: the value of thelightWeightPopupEnabled
propertyGets the value of the |
| private boolean | |
| public boolean | Returns: true if the popup is visible, otherwise returns falseDetermines the visibility of the popup. |
| protected String | Returns: a string representation of thisJComboBoxOverrides javax. Returns a string representation of this |
| protected boolean | processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)
Overrides javax. Invoked to process the key bindings for |
| public void | processKeyEvent(KeyEvent
the e)KeyEvent containing the keyboard
key that was pressedOverrides javax. Handles |
| public void | |
| public void | |
| public void | removeItem(Object
the object to remove from the item list anObject)Removes an item from the item list. |
| public void | removeItemAt(int
an int specifying the index of the item to remove,
where 0
indicates the first item in the list anIndex)Removes the item at |
| public void | removeItemListener(ItemListener
the aListener)ItemListener to removeImplements java. Removes an |
| public void | removePopupMenuListener(PopupMenuListener
the l)PopupMenuListener to removeRemoves a |
| protected void | |
| public boolean | Returns: true if there is an item corresponding to that character.
Otherwise, returns false.a char, typically this is a keyboard key
typed by the user keyChar)Selects the list item that corresponds to the specified keyboard character and returns true, if there is an item corresponding to that character. |
| public void | |
| public void | setActionCommand(String
a string containing the "command" that is sent
to action listeners; the same listener can then
do different things depending on the command it
receives aCommand)Sets the action command that should be included in the event sent to action listeners. |
| private void | |
| public void | setEditable(boolean
a boolean value, where true indicates that the
field is editable aFlag)Determines whether the |
| public void | setEditor(ComboBoxEditor
the anEditor)ComboBoxEditor that
displays the selected itemSets the editor used to paint and edit the selected item in the
|
| public void | setEnabled(boolean
a boolean value, where true enables the component and
false disables it b)Overrides javax. Enables the combo box so that items can be selected. |
| public void | setKeySelectionManager(JComboBox.
a key selection manager aManagerSets the object that translates a keyboard character into a list selection. |
| public void | setLightWeightPopupEnabled(boolean
if aFlag)true, lightweight popups are desiredSets the |
| public void | setMaximumRowCount(int
an integer specifying the maximum number of items to
display in the list before using a scrollbar count)Sets the maximum number of rows the |
| public void | setModel(ComboBoxModel<E>
the aModel)ComboBoxModel that provides the
displayed list of itemsSets the data model that the |
| public void | setPopupVisible(boolean
if v)true shows the popup, otherwise, hides the popup.Sets the visibility of the popup. |
| public void | setPrototypeDisplayValue(E
the prototype display value prototypeDisplayValue)Sets the prototype display value used to calculate the size of the display for the UI portion. |
| public void | setRenderer(ListCellRenderer<? super E>
the aRenderer)ListCellRenderer that
displays the selected itemSets the renderer that paints the list items and the item selected from the list in the JComboBox field. |
| public void | setSelectedIndex(int
an integer specifying the list item to select,
where 0 specifies the first item in the list and -1 indicates no selection anIndex)Selects the item at index |
| public void | setSelectedItem(Object
the list object to select; use anObject)null to
clear the selectionSets the selected item in the combo box display area to the object in the argument. |
| public void | |
| public void | |
| public void | updateUI()
Overrides javax. Resets the UI property to a value from the current look and feel. |
| private void | writeObject(ObjectOutputStream s)
Hides javax. See |