org.jminor.common.model.combobox
Class ItemComboBoxModel<T>

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by javax.swing.DefaultComboBoxModel
          extended by org.jminor.common.model.combobox.ItemComboBoxModel<T>
All Implemented Interfaces:
Serializable, ComboBoxModel, ListModel, MutableComboBoxModel, Refreshable
Direct Known Subclasses:
BooleanComboBoxModel

public class ItemComboBoxModel<T>
extends DefaultComboBoxModel
implements Refreshable

A ComboBoxModel implementation based on the ItemComboBoxModel.Item class.

See Also:
Serialized Form

Nested Class Summary
static class ItemComboBoxModel.IconItem<T>
          An IconItem to use in a ItemComboBoxModel.
 
Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
ItemComboBoxModel()
          Constructs a new ItemComboBoxModel.
ItemComboBoxModel(Item<T>... items)
          Constructs a new ItemComboBoxModel
ItemComboBoxModel(List<Item<T>> items)
          Constructs a new ItemComboBoxModel
 
Method Summary
 void clear()
          Clears all data from this refreshable instance
 int getIndexOfItem(Object item)
           
 Item<T> getSelectedItem()
          
protected  void initializeItems(List<Item<T>> items)
           
 void refresh()
          Clears the model and adds all the items
 void setSelectedItem(Object anObject)
          
 
Methods inherited from class javax.swing.DefaultComboBoxModel
addElement, getElementAt, getIndexOf, getSize, insertElementAt, removeAllElements, removeElement, removeElementAt
 
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
 

Constructor Detail

ItemComboBoxModel

public ItemComboBoxModel()
Constructs a new ItemComboBoxModel.


ItemComboBoxModel

public ItemComboBoxModel(Item<T>... items)
Constructs a new ItemComboBoxModel

Parameters:
items - the items

ItemComboBoxModel

public ItemComboBoxModel(List<Item<T>> items)
Constructs a new ItemComboBoxModel

Parameters:
items - the items
Method Detail

setSelectedItem

public final void setSelectedItem(Object anObject)

Specified by:
setSelectedItem in interface ComboBoxModel
Overrides:
setSelectedItem in class DefaultComboBoxModel

getIndexOfItem

public final int getIndexOfItem(Object item)
Parameters:
item - the item
Returns:
the index of the given item

getSelectedItem

public final Item<T> getSelectedItem()

Specified by:
getSelectedItem in interface ComboBoxModel
Overrides:
getSelectedItem in class DefaultComboBoxModel

clear

public final void clear()
Clears all data from this refreshable instance

Specified by:
clear in interface Refreshable

refresh

public void refresh()
Clears the model and adds all the items

Specified by:
refresh in interface Refreshable

initializeItems

protected final void initializeItems(List<Item<T>> items)