E
- the type of the elements of this modelpublic class DefaultComboBoxModel<E> extends AbstractListModel<E> implements MutableComboBoxModel<E>, Serializable
The default model for combo boxes.
listenerList
public DefaultComboBoxModel()
Constructs an empty DefaultComboBoxModel object.
public DefaultComboBoxModel(E[] items)
Constructs a DefaultComboBoxModel object initialized with an array of objects.
items
- an array of Object objectspublic DefaultComboBoxModel(Vector<E> v)
Constructs a DefaultComboBoxModel object initialized with a vector.
v
- a Vector object ...public void setSelectedItem(Object anObject)
Set the value of the selected item. The selected item may be null.
setSelectedItem
in interface ComboBoxModel<E>
anObject
- The combo box value or null for no selection.public Object getSelectedItem()
Description copied from interface: ComboBoxModel
Returns the selected item
getSelectedItem
in interface ComboBoxModel<E>
null
if there is no selectionpublic int getSize()
Description copied from interface: ListModel
Returns the length of the list.
public E getElementAt(int index)
Description copied from interface: ListModel
Returns the value at the specified index.
getElementAt
in interface ListModel<E>
index
- the requested indexindex
public int getIndexOf(Object anObject)
Returns the index-position of the specified object in the list.
anObject
- public void addElement(E anObject)
Description copied from interface: MutableComboBoxModel
Adds an item at the end of the model. The implementation of this method should notify all registered ListDataListener
s that the item has been added.
addElement
in interface MutableComboBoxModel<E>
anObject
- the item to be addedpublic void insertElementAt(E anObject, int index)
Description copied from interface: MutableComboBoxModel
Adds an item at a specific index. The implementation of this method should notify all registered ListDataListener
s that the item has been added.
insertElementAt
in interface MutableComboBoxModel<E>
anObject
- the item to be addedindex
- location to add the objectpublic void removeElementAt(int index)
Description copied from interface: MutableComboBoxModel
Removes an item at a specific index. The implementation of this method should notify all registered ListDataListener
s that the item has been removed.
removeElementAt
in interface MutableComboBoxModel<E>
index
- location of the item to be removedpublic void removeElement(Object anObject)
Description copied from interface: MutableComboBoxModel
Removes an item from the model. The implementation of this method should should notify all registered ListDataListener
s that the item has been removed.
removeElement
in interface MutableComboBoxModel<E>
anObject
- the Object
to be removedpublic void removeAllElements()
Empties the list.
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.