E - the type of the elements of this model
public class DefaultComboBoxModel<E> extends AbstractListModel<E> implements MutableComboBoxModel <E>, Serializable
listenerList| Constructor and Description |
|---|
DefaultComboBoxModel()
Constructs an empty DefaultComboBoxModel object.
|
DefaultComboBoxModel(E[] items)
Constructs a DefaultComboBoxModel object initialized with an array of objects.
|
DefaultComboBoxModel(Vector
Constructs a DefaultComboBoxModel object initialized with a vector.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addElement(E anObject)
Adds an item at the end of the model.
|
E |
getElementAt(int index)
Returns the value at the specified index.
|
int |
getIndexOf(Object
Returns the index-position of the specified object in the list.
|
Object |
getSelectedItem()
Returns the selected item
|
int |
getSize()
Returns the length of the list.
|
void |
insertElementAt(E anObject, int index)
Adds an item at a specific index.
|
void |
removeAllElements()
Empties the list.
|
void |
removeElement(Object
Removes an item from the model.
|
void |
removeElementAt(int index)
Removes an item at a specific index.
|
void |
setSelectedItem(Object
Set the value of the selected item.
|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddListDataListener, removeListDataListenerpublic DefaultComboBoxModel()
public DefaultComboBoxModel(E[] items)
items - an array of Object objects
public void setSelectedItem(ObjectanObject)
setSelectedItem in interface
ComboBoxModel<E>
anObject - The combo box value or null for no selection.
public ObjectgetSelectedItem()
ComboBoxModel
getSelectedItem in interface
ComboBoxModel<E>
null if there is no selection
public int getSize()
ListModel
public E getElementAt(int index)
ListModel
getElementAt in interface
ListModel<E>
index - the requested index
index
public int getIndexOf(ObjectanObject)
anObject -
public void addElement(E anObject)
MutableComboBoxModel
ListDataListeners that the item has been added.
addElement in interface
MutableComboBoxModel<E>
anObject - the item to be added
public void insertElementAt(E anObject, int index)
MutableComboBoxModel
ListDataListeners that the item has been added.
insertElementAt in interface
MutableComboBoxModel<E>
anObject - the item to be added
index - location to add the object
public void removeElementAt(int index)
MutableComboBoxModel
ListDataListeners that the item has been removed.
removeElementAt in interface
MutableComboBoxModel<E>
index - location of the item to be removed
public void removeElement(ObjectanObject)
MutableComboBoxModel
ListDataListeners that the item has been removed.
removeElement in interface
MutableComboBoxModel<E>
anObject - the
Object to be removed
public void removeAllElements()