javax.swing
Class DefaultComboBoxModel
- ComboBoxModel, ListModel, MutableComboBoxModel, Serializable
The default implementation of
MutableComboBoxModel
.
This model keeps track
of elements contained in the JComboBox as well as the current combo box
selection. Whenever selection in the JComboBox changes, the ComboBoxModel
will fire ListDataEvents to ComboBox's ListDataListeners.
- Serialized Form
void | addElement(Object object) - This method adds element to the combo box list.
|
Object | getElementAt(int index) - Returns element in the combo box list located at the given index
|
int | getIndexOf(Object object) - Returns index of the specified object in the combo box list.
|
Object | getSelectedItem() - Returns currently selected item in the combo box list
|
int | getSize() - Returns number of items in the combo box list
|
void | insertElementAt(Object object, int index) - This method inserts given object to the combo box list at the specified
index.
|
void | removeAllElements() - Removes all the items from the JComboBox's item list.
|
void | removeElement(Object object) - Removes given object from the combo box list.
|
void | removeElementAt(int index) - This method removes element at the specified index from the combo box
list.
|
void | setSelectedItem(Object object) - Selects given object in the combo box list.
|
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
DefaultComboBoxModel
public DefaultComboBoxModel()
Constructor DefaultComboBoxModel. Create empty JComboBox.
DefaultComboBoxModel
public DefaultComboBoxModel(Object[] items)
Constructs new DefaultComboBoxModel object and initializes its item list
to values in the given array.
items
- array containing items of the combo box.
DefaultComboBoxModel
public DefaultComboBoxModel(Vector vector)
Consturcts new DefaultComboBoxModel object and initializes its item list
to values in the given vector.
vector
- Vector containing items for this combo box.
addElement
public void addElement(Object object)
This method adds element to the combo box list. It fires ListDataEvent
indicating that component was added to the combo box to all of the
JComboBox's registered ListDataListeners.
- addElement in interface MutableComboBoxModel
object
- item to add to the combo box list
getElementAt
public Object getElementAt(int index)
Returns element in the combo box list located at the given index
- getElementAt in interface ListModel
index
- specifying location of the element in the list
- return element in the combo box list located at the given index
getIndexOf
public int getIndexOf(Object object)
Returns index of the specified object in the combo box list.
object
- element to look for in the combo box list .
- Index specifying position of the specified element in combo box
list.
getSize
public int getSize()
Returns number of items in the combo box list
- getSize in interface ListModel
- number of items in the combo box list
insertElementAt
public void insertElementAt(Object object,
int index)
This method inserts given object to the combo box list at the specified
index. It fires ListDataEvent indicating that component was inserted to
the combo box list to all of the JComboBox's registered
ListDataListeners.
- insertElementAt in interface MutableComboBoxModel
object
- element to insertindex
- index specifing position in the list where given element
should be inserted.
removeAllElements
public void removeAllElements()
Removes all the items from the JComboBox's item list. It fires
ListDataEvent indicating that all the elements were removed from the
combo box list to all of the JComboBox's registered ListDataListeners.
removeElement
public void removeElement(Object object)
Removes given object from the combo box list. It fires ListDataEvent
indicating that component was removed from the combo box list to all of
the JComboBox's registered ListDataListeners.
- removeElement in interface MutableComboBoxModel
object
- Element that will be removed from the combo box list
removeElementAt
public void removeElementAt(int index)
This method removes element at the specified index from the combo box
list. It fires ListDataEvent indicating that component was removed from
the combo box list to all of the JComboBox's registered
ListDataListeners.
- removeElementAt in interface MutableComboBoxModel
index
- index specifying location of the element to remove in the
combo box list.
setSelectedItem
public void setSelectedItem(Object object)
Selects given object in the combo box list. This method fires
ListDataEvent to all registered ListDataListeners of the JComboBox. The
start and end index of the event is set to -1 to indicate combo box's
selection has changed, and not its contents.
If the given object is not contained in the combo box list then nothing
happens.
- setSelectedItem in interface ComboBoxModel
object
- item to select in the JComboBox
DefaultComboBoxModel.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.