Groovy Documentation

com.wordpress.tipsforjava.swing
[Java] Class SortedComboBoxModel

java.lang.Object
  javax.swing.AbstractListModel
      javax.swing.DefaultComboBoxModel
          com.wordpress.tipsforjava.swing.SortedComboBoxModel

class SortedComboBoxModel
extends DefaultComboBoxModel

Custom model to make sure the items are stored in a sorted order. The default is to sort in the natural order of the item, but a Comparator can be used to customize the sort order. The data is initially sorted before the model is created. Any updates to the model will cause the items to be inserted in sorted order.

Authors:
Rob Camick
Darryl Burke


Field Summary
private Comparator comparator

 
Constructor Summary
SortedComboBoxModel()

SortedComboBoxModel(Comparator comparator)

SortedComboBoxModel(Object[] items)

SortedComboBoxModel(Object[] items, Comparator comparator)

SortedComboBoxModel(Vector items)

SortedComboBoxModel(Vector items, Comparator comparator)

 
Method Summary
void addElement(Object element)

void insertElementAt(Object element, int index)

protected static Object[] sortArray(Object[] items, Comparator comparator)

protected static Vector sortVector(Vector items, Comparator comparator)

 
Methods inherited from class DefaultComboBoxModel
addElement, getSize, removeElementAt, insertElementAt, removeElement, removeAllElements, setSelectedItem, getSelectedItem, getElementAt, getIndexOf, getListeners, addListDataListener, removeListDataListener, getListDataListeners, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 
Methods inherited from class AbstractListModel
getListeners, addListDataListener, removeListDataListener, getListDataListeners, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll, getSize, getElementAt
 

Field Detail

comparator

private Comparator comparator


 
Constructor Detail

SortedComboBoxModel

public SortedComboBoxModel()


SortedComboBoxModel

public SortedComboBoxModel(Comparator comparator)


SortedComboBoxModel

public SortedComboBoxModel(Object[] items)


SortedComboBoxModel

public SortedComboBoxModel(Object[] items, Comparator comparator)


SortedComboBoxModel

public SortedComboBoxModel(Vector items)


SortedComboBoxModel

public SortedComboBoxModel(Vector items, Comparator comparator)


 
Method Detail

addElement

de
	public
public void addElement(Object element)


insertElementAt

ssWarnings("unchecked")
	@Overri
de
	public
public void insertElementAt(Object element, int index)


sortArray

ssWarnings("unchecked")
	protect
protected static Object[] sortArray(Object[] items, Comparator comparator)


sortVector

ssWarnings("unchecked")
	protect
protected static Vector sortVector(Vector items, Comparator comparator)


 

Groovy Documentation