javax.swing
public class DefaultComboBoxModel extends AbstractListModel implements MutableComboBoxModel, Serializable
null
). Changes to the model are signalled to listeners using
ListDataEvent. This model is designed for use by the
JComboBox component.
Constructor Summary | |
---|---|
DefaultComboBoxModel()
Creates a new model, initially empty. | |
DefaultComboBoxModel(Object[] items)
Creates a new model and initializes its item list to the values in the
given array. | |
DefaultComboBoxModel(Vector<?> vector)
Creates a new model and initializes its item list to the values in the
given vector. |
Method Summary | |
---|---|
void | addElement(Object object)
Adds an element to the model's item list and sends a ListDataEvent
to all registered listeners. |
Object | getElementAt(int index)
Returns the element at the specified index in the model's item list.
|
int | getIndexOf(Object object)
Returns the index of the specified element in the model's item list.
|
Object | getSelectedItem()
Returns the selected item.
|
int | getSize()
Returns the number of items in the model's item list.
|
void | insertElementAt(Object object, int index)
Adds an element at the specified index in the model's item list
and sends a ListDataEvent to all registered listeners.
|
void | removeAllElements()
Removes all the items from the model's item list, resets and selected item
to null , and sends a ListDataEvent to all registered
listeners. |
void | removeElement(Object object)
Removes an element from the model's item list and sends a
ListDataEvent to all registered listeners. |
void | removeElementAt(int index)
Removes the element at the specified index from the model's item list
and sends a ListDataEvent to all registered listeners. |
void | setSelectedItem(Object object)
Sets the selected item for the model and sends a ListDataEvent to
all registered listeners. |
null
if the array length is zero.
Parameters: items an array containing items for the model (null
not permitted).
Throws: NullPointerException if items
is null
.
null
if the vector length is zero.
Parameters: vector a vector containing items for the model (null
not permitted).
Throws: NullPointerException if vector
is null
.
null
, the new element
is set as the selected item.
Parameters: object item to add to the model's item list.
Parameters: index the element index.
Returns: The element at the specified index in the model's item list, or
null
if the index
is outside the bounds
of the list.
Parameters: object the element.
Returns: The index of the specified element in the model's item list.
Returns: The selected item (possibly null
).
Returns: The number of items in the model's item list.
Parameters: object element to insert index index specifing position in the list where given element should be inserted.
Throws: ArrayIndexOutOfBoundsException if index
is out of
bounds.
See Also: addElement
null
, and sends a ListDataEvent to all registered
listeners.Parameters: object the element to remove.
Parameters: index the index of the item to remove.
Throws: ArrayIndexOutOfBoundsException if index
is out of
bounds.
Parameters: object the new selected item (null
permitted).