jgnash.ui.components
Class SortedComboBoxModel<E extends java.lang.Comparable<? super E>>
java.lang.Object
javax.swing.AbstractListModel
jgnash.ui.components.SortedComboBoxModel<E>
- Type Parameters:
E - Model type
- All Implemented Interfaces:
- java.io.Serializable, javax.swing.ComboBoxModel, javax.swing.ListModel, javax.swing.MutableComboBoxModel
public class SortedComboBoxModel<E extends java.lang.Comparable<? super E>>
- extends javax.swing.AbstractListModel
- implements javax.swing.MutableComboBoxModel
A ComboBoxModel that maintains the list in a sorted order
- Version:
- $Id$
- Author:
- Craig Cavanaugh
- See Also:
- Serialized Form
| Fields inherited from class javax.swing.AbstractListModel |
listenerList |
| 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 |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
selectedObject
private java.lang.Object selectedObject
list
private java.util.List<E extends java.lang.Comparable<? super E>> list
SortedComboBoxModel
public SortedComboBoxModel()
SortedComboBoxModel
public SortedComboBoxModel(java.util.Collection<E> items)
- Constructs a SortedComboBoxModel object initialized with
an Collection of objects.
- Parameters:
items - an array of Object objects
clear
public void clear()
addAll
public void addAll(java.util.Collection<E> items)
setSelectedItem
public void setSelectedItem(java.lang.Object anObject)
- Set the value of the selected item. The selected item may be null.
- Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel
- Parameters:
anObject - The combo box value or null for no selection.
getSelectedItem
public java.lang.Object getSelectedItem()
- Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel
getSize
public int getSize()
- Specified by:
getSize in interface javax.swing.ListModel
getElementAt
public java.lang.Object getElementAt(int index)
- Specified by:
getElementAt in interface javax.swing.ListModel
getIndexOf
int getIndexOf(java.lang.Object anObject)
- Returns the index-position of the specified object in the list.
- Parameters:
anObject - object to find index for
- Returns:
- an int representing the index position, where 0 is
the first position
updateElement
public void updateElement(java.lang.Object anObject)
add
private int add(E anObject)
removeElementAt
public void removeElementAt(int index)
- Specified by:
removeElementAt in interface javax.swing.MutableComboBoxModel
removeElement
public void removeElement(java.lang.Object anObject)
- Specified by:
removeElement in interface javax.swing.MutableComboBoxModel
removeAllElements
public void removeAllElements()
- Empties the list.
addElement
public void addElement(java.lang.Object obj)
- Specified by:
addElement in interface javax.swing.MutableComboBoxModel
insertElementAt
public void insertElementAt(java.lang.Object obj,
int index)
- Specified by:
insertElementAt in interface javax.swing.MutableComboBoxModel