public class DefaultComboBoxModel extends AbstractListModel implements MutableComboBoxModel, Serializable
listenerList
Constructor and Description |
---|
DefaultComboBoxModel()
Constructs an empty DefaultComboBoxModel object.
|
DefaultComboBoxModel(Object[] items)
Constructs a DefaultComboBoxModel object initialized with
an array of objects.
|
DefaultComboBoxModel(Vector<?> v)
Constructs a DefaultComboBoxModel object initialized with
a vector.
|
Modifier and Type | Method and Description |
---|---|
void |
addElement(Object anObject)
Adds an item at the end of the model.
|
Object |
getElementAt(int index)
Returns the value at the specified index.
|
int |
getIndexOf(Object anObject)
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(Object anObject,
int index)
Adds an item at a specific index.
|
void |
removeAllElements()
Empties the list.
|
void |
removeElement(Object anObject)
Removes an item from the model.
|
void |
removeElementAt(int index)
Removes an item at a specific index.
|
void |
setSelectedItem(Object anObject)
Set the value of the selected item.
|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListDataListener, removeListDataListener
public DefaultComboBoxModel()
public DefaultComboBoxModel(Object[] items)
items
- an array of Object objectspublic DefaultComboBoxModel(Vector<?> v)
v
- a Vector object ...public void setSelectedItem(Object anObject)
setSelectedItem
in interface ComboBoxModel
anObject
- The combo box value or null for no selection.public Object getSelectedItem()
ComboBoxModel
getSelectedItem
in interface ComboBoxModel
null
if there is no selectionpublic int getSize()
ListModel
public Object getElementAt(int index)
ListModel
getElementAt
in interface ListModel
index
- the requested indexindex
public int getIndexOf(Object anObject)
anObject
- public void addElement(Object anObject)
MutableComboBoxModel
ListDataListener
s that the
item has been added.addElement
in interface MutableComboBoxModel
anObject
- the Object
to be addedpublic void insertElementAt(Object anObject, int index)
MutableComboBoxModel
ListDataListener
s that the
item has been added.insertElementAt
in interface MutableComboBoxModel
anObject
- the Object
to be addedindex
- location to add the objectpublic void removeElementAt(int index)
MutableComboBoxModel
ListDataListener
s that the
item has been removed.removeElementAt
in interface MutableComboBoxModel
index
- location of object to be removedpublic void removeElement(Object anObject)
MutableComboBoxModel
ListDataListener
s that the
item has been removed.removeElement
in interface MutableComboBoxModel
anObject
- the Object
to be removedpublic void removeAllElements()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2011, Oracle and/or its affiliates. All rights reserved.
DRAFT ea-b138