javax.swing
Class DefaultComboBoxModel

java.lang.Object
  |
  +--javax.swing.AbstractListModel
        |
        +--javax.swing.DefaultComboBoxModel
All Implemented Interfaces:
ComboBoxModel, ListModel, MutableComboBoxModel, Serializable

public class DefaultComboBoxModel
extends AbstractListModel
implements MutableComboBoxModel, Serializable

Safe: The default model for combo boxes.

Version:
1.15 12/03/01
Author:
Arnaud Weber, Tom Santos
See Also:
Serialized Form

Field Summary
(package private)  Vector objects
           
(package private)  Object selectedObject
           
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
DefaultComboBoxModel()
          Enabled: Constructs an empty DefaultComboBoxModel object.
DefaultComboBoxModel(Object[] items)
          Enabled: Constructs a DefaultComboBoxModel object initialized with an array of objects.
DefaultComboBoxModel(Vector v)
          Enabled: Constructs a DefaultComboBoxModel object initialized with a vector.
 
Method Summary
 void addElement(Object anObject)
          Enabled:
 Object getElementAt(int index)
          Enabled:
 int getIndexOf(Object anObject)
          Enabled: Returns the index-position of the specified object in the list.
 Object getSelectedItem()
          Enabled:
 int getSize()
          Enabled:
 void insertElementAt(Object anObject, int index)
          Enabled:
 void removeAllElements()
          Enabled: Empties the list.
 void removeElement(Object anObject)
          Enabled:
 void removeElementAt(int index)
          Enabled:
 void setSelectedItem(Object anObject)
          Enabled: Set the value of the selected item.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
 

Field Detail

objects

Vector objects

selectedObject

Object selectedObject
Constructor Detail

DefaultComboBoxModel

public DefaultComboBoxModel()
Enabled: Constructs an empty DefaultComboBoxModel object.


DefaultComboBoxModel

public DefaultComboBoxModel(Object[] items)
Enabled: Constructs a DefaultComboBoxModel object initialized with an array of objects.

Parameters:
items - an array of Object objects

DefaultComboBoxModel

public DefaultComboBoxModel(Vector v)
Enabled: Constructs a DefaultComboBoxModel object initialized with a vector.

Parameters:
v - a Vector object ...
Method Detail

setSelectedItem

public void setSelectedItem(Object anObject)
Enabled: Set the value of the selected item. The selected item may be null.

Specified by:
setSelectedItem in interface ComboBoxModel
Parameters:
anObject - The combo box value or null for no selection.

getSelectedItem

public Object getSelectedItem()
Enabled:

Specified by:
getSelectedItem in interface ComboBoxModel
Returns:
The selected item or null if there is no selection

getSize

public int getSize()
Enabled:

Specified by:
getSize in interface ListModel
Returns:
the length of the list

getElementAt

public Object getElementAt(int index)
Enabled:

Specified by:
getElementAt in interface ListModel
Parameters:
index - the requested index
Returns:
the value at index

getIndexOf

public int getIndexOf(Object anObject)
Enabled: Returns the index-position of the specified object in the list.

Parameters:
anObject -
Returns:
an int representing the index position, where 0 is the first position

addElement

public void addElement(Object anObject)
Enabled:

Specified by:
addElement in interface MutableComboBoxModel
Parameters:
anObject - the Object to be added

insertElementAt

public void insertElementAt(Object anObject,
                            int index)
Enabled:

Specified by:
insertElementAt in interface MutableComboBoxModel
Parameters:
anObject - the Object to be added
index - location to add the object

removeElementAt

public void removeElementAt(int index)
Enabled:

Specified by:
removeElementAt in interface MutableComboBoxModel
Parameters:
index - location of object to be removed

removeElement

public void removeElement(Object anObject)
Enabled:

Specified by:
removeElement in interface MutableComboBoxModel
Parameters:
anObject - the Object to be removed

removeAllElements

public void removeAllElements()
Enabled: Empties the list.



comments?