APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing

public Class DefaultComboBoxModel<E>

extends AbstractListModel<E>
implements MutableComboBoxModel<E>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.swing.MutableComboBoxModel, javax.swing.ComboBoxModel, javax.swing.ListModel
Known Direct Subclasses
javax.swing.text.html.OptionComboBoxModel
Annotations
@SuppressWarnings:serial
Type Parameters
<E>
the type of the elements of this model
Imports
java.util.Collection, .Vector, java.io.Serializable

The default model for combo boxes.
Authors
Arnaud Weber, Tom Santos
Since
1.2

Field Summary

Modifier and TypeField and Description
pack-priv Vector<E>
pack-priv Object
Inherited from javax.swing.AbstractListModel:
listenerList

Constructor Summary

AccessConstructor and Description
public
DefaultComboBoxModel()

Constructs an empty DefaultComboBoxModel object.

public
DefaultComboBoxModel(final E[]
an array of Object objects
items
)

Constructs a DefaultComboBoxModel object initialized with an array of objects.

public
DefaultComboBoxModel(Vector<E>
a Vector object ...
v
)

Constructs a DefaultComboBoxModel object initialized with a vector.

Method Summary

Modifier and TypeMethod and Description
public void
addAll(Collection<? extends E>
the collection which contains the elements to add
c
)

Adds all of the elements present in the collection.

public void
addAll(int
index at which to insert the first element from the specified collection
index
,
Collection<? extends E>
the collection which contains the elements to add
c
)

Adds all of the elements present in the collection, starting from the specified index.

public void
addElement(E anObject)

Implements javax.swing.MutableComboBoxModel.addElement.

Adds an item at the end of the model.

public E
getElementAt(int index)

Implements javax.swing.ListModel.getElementAt.

Returns the value at the specified index.

public int

Returns:

an int representing the index position, where 0 is the first position
getIndexOf
(Object
the object to return the index of
anObject
)

Returns the index-position of the specified object in the list.

public Object
getSelectedItem()

Implements javax.swing.ComboBoxModel.getSelectedItem.

Returns the selected item

public int
getSize()

Implements javax.swing.ListModel.getSize.

Returns the length of the list.

public void
insertElementAt(E anObject, int index)

Implements javax.swing.MutableComboBoxModel.insertElementAt.

Adds an item at a specific index.

public void
removeAllElements()

Empties the list.

public void
removeElement(Object anObject)

Implements javax.swing.MutableComboBoxModel.removeElement.

Removes an item from the model.

public void
removeElementAt(int index)

Implements javax.swing.MutableComboBoxModel.removeElementAt.

Removes an item at a specific index.

public void
setSelectedItem(Object
The combo box value or null for no selection.
anObject
)

Implements javax.swing.ComboBoxModel.setSelectedItem.

Set the value of the selected item.

Inherited from javax.swing.AbstractListModel:
addListDataListenerfireContentsChangedfireIntervalAddedfireIntervalRemovedgetListDataListenersgetListenersremoveListDataListener

Field Detail

objectsback to summary
pack-priv Vector<E> objects
selectedObjectback to summary
pack-priv Object selectedObject

Constructor Detail

DefaultComboBoxModelback to summary
public DefaultComboBoxModel()

Constructs an empty DefaultComboBoxModel object.

DefaultComboBoxModelback to summary
public DefaultComboBoxModel(final E[] items)

Constructs a DefaultComboBoxModel object initialized with an array of objects.

Parameters
items:E[]

an array of Object objects

DefaultComboBoxModelback to summary
public DefaultComboBoxModel(Vector<E> v)

Constructs a DefaultComboBoxModel object initialized with a vector.

Parameters
v:Vector<E>

a Vector object ...

Method Detail

addAllback to summary
public void addAll(Collection<? extends E> c)

Adds all of the elements present in the collection.

Parameters
c:Collection<? extends E>

the collection which contains the elements to add

Exceptions
NullPointerException:
if c is null
Since
11
addAllback to summary
public void addAll(int index, Collection<? extends E> c)

Adds all of the elements present in the collection, starting from the specified index.

Parameters
index:int

index at which to insert the first element from the specified collection

c:Collection<? extends E>

the collection which contains the elements to add

Exceptions
ArrayIndexOutOfBoundsException:
if index does not fall within the range of number of elements currently held
NullPointerException:
if c is null
Since
11
addElementback to summary
public void addElement(E anObject)

Implements javax.swing.MutableComboBoxModel.addElement.

Doc from javax.swing.MutableComboBoxModel.addElement.

Adds an item at the end of the model. The implementation of this method should notify all registered ListDataListeners that the item has been added.

getElementAtback to summary
public E getElementAt(int index)

Implements javax.swing.ListModel.getElementAt.

Doc from javax.swing.ListModel.getElementAt.

Returns the value at the specified index.

getIndexOfback to summary
public int getIndexOf(Object anObject)

Returns the index-position of the specified object in the list.

Parameters
anObject:Object

the object to return the index of

Returns:int

an int representing the index position, where 0 is the first position

getSelectedItemback to summary
public Object getSelectedItem()

Implements javax.swing.ComboBoxModel.getSelectedItem.

Doc from javax.swing.ComboBoxModel.getSelectedItem.

Returns the selected item

getSizeback to summary
public int getSize()

Implements javax.swing.ListModel.getSize.

Doc from javax.swing.ListModel.getSize.

Returns the length of the list.

insertElementAtback to summary
public void insertElementAt(E anObject, int index)

Implements javax.swing.MutableComboBoxModel.insertElementAt.

Doc from javax.swing.MutableComboBoxModel.insertElementAt.

Adds an item at a specific index. The implementation of this method should notify all registered ListDataListeners that the item has been added.

removeAllElementsback to summary
public void removeAllElements()

Empties the list.

removeElementback to summary
public void removeElement(Object anObject)

Implements javax.swing.MutableComboBoxModel.removeElement.

Doc from javax.swing.MutableComboBoxModel.removeElement.

Removes an item from the model. The implementation of this method should should notify all registered ListDataListeners that the item has been removed.

removeElementAtback to summary
public void removeElementAt(int index)

Implements javax.swing.MutableComboBoxModel.removeElementAt.

Doc from javax.swing.MutableComboBoxModel.removeElementAt.

Removes an item at a specific index. The implementation of this method should notify all registered ListDataListeners that the item has been removed.

setSelectedItemback to summary
public void setSelectedItem(Object anObject)

Implements javax.swing.ComboBoxModel.setSelectedItem.

Set the value of the selected item. The selected item may be null.

Parameters
anObject:Object

The combo box value or null for no selection.