de.tkuhn.swing.combobox
Class CascadingComboBoxModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by javax.swing.DefaultComboBoxModel
          extended by de.tkuhn.swing.combobox.CascadingComboBoxModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.ComboBoxModel, javax.swing.ListModel, javax.swing.MutableComboBoxModel

public class CascadingComboBoxModel
extends javax.swing.DefaultComboBoxModel

The CascadingComboBoxModel is a means to provide a row of combo boxes where the items selectable in one combobox depend on the selected item in the previous combo box.

Version:
0.9.3
Author:
Tilmann Kuhn
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
CascadingComboBoxModel()
          Creates a new CascadingComboBoxModel.
CascadingComboBoxModel(javax.swing.ComboBoxModel superModel)
          Creates a new CascadingComboBoxModel with the given super model
CascadingComboBoxModel(java.lang.Object superSelected)
          Creates a new CascadingComboBoxModel with contents based on the given object a it was selected in the super model.
CascadingComboBoxModel(java.lang.Object[] items)
          Constructs a CascadingComboBoxModel object initialized with an array of objects.
CascadingComboBoxModel(java.lang.Object[] items, javax.swing.ComboBoxModel superModel)
          Constructs a CascadingComboBoxModel object initialized with an array of objects and the given super model.
CascadingComboBoxModel(java.util.Vector<?> v)
          Constructs a CascadingComboBoxModel object initialized with a vector.
CascadingComboBoxModel(java.util.Vector<?> v, javax.swing.ComboBoxModel superModel)
          Constructs a CascadingComboBoxModel object initialized with a vector and the given super model.
 
Method Summary
 void computeNewContents(java.lang.Object superSelected)
          Compute the new Contents based on the new object selected in the super model.
 javax.swing.ComboBoxModel getSuperModel()
          Getter for property superModel.
 java.lang.Object getSuperSelected()
          Getter for property superSelected.
 void setSuperModel(javax.swing.ComboBoxModel superModel)
          Setter for property superModel.
protected  void setSuperSelected(java.lang.Object selected)
          Sets the new selected element of the super model only if it changed.
 
Methods inherited from class javax.swing.DefaultComboBoxModel
addElement, getElementAt, getIndexOf, getSelectedItem, getSize, insertElementAt, removeAllElements, removeElement, removeElementAt, setSelectedItem
 
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

CascadingComboBoxModel

public CascadingComboBoxModel()
Creates a new CascadingComboBoxModel.


CascadingComboBoxModel

public CascadingComboBoxModel(javax.swing.ComboBoxModel superModel)
Creates a new CascadingComboBoxModel with the given super model

Parameters:
superModel - the model this model depends on

CascadingComboBoxModel

public CascadingComboBoxModel(java.lang.Object superSelected)
Creates a new CascadingComboBoxModel with contents based on the given object a it was selected in the super model. The supermodel itself must still be set!

Parameters:
superSelected - the virtually selected Object

CascadingComboBoxModel

public CascadingComboBoxModel(java.lang.Object[] items)
Constructs a CascadingComboBoxModel object initialized with an array of objects. The supermodel itself must still be set!

Parameters:
items - the items put into the combo box

CascadingComboBoxModel

public CascadingComboBoxModel(java.util.Vector<?> v)
Constructs a CascadingComboBoxModel object initialized with a vector. The supermodel itself must still be set!

Parameters:
v - a vector containing the items put into the combo box

CascadingComboBoxModel

public CascadingComboBoxModel(java.lang.Object[] items,
                              javax.swing.ComboBoxModel superModel)
Constructs a CascadingComboBoxModel object initialized with an array of objects and the given super model.

Parameters:
items - the items put into the combo box
superModel - the model this model depends on

CascadingComboBoxModel

public CascadingComboBoxModel(java.util.Vector<?> v,
                              javax.swing.ComboBoxModel superModel)
Constructs a CascadingComboBoxModel object initialized with a vector and the given super model.

Parameters:
v - a vector containing the items put into the combo box
superModel - the model this model depends on
Method Detail

getSuperModel

public javax.swing.ComboBoxModel getSuperModel()
Getter for property superModel.

Returns:
Value of property superModel.

setSuperModel

public void setSuperModel(javax.swing.ComboBoxModel superModel)
Setter for property superModel.

Parameters:
superModel - New value of property superModel.

setSuperSelected

protected void setSuperSelected(java.lang.Object selected)
Sets the new selected element of the super model only if it changed. This method is invoked each time the selected item in the super model changes and invokes itself the method computeNewContents()

Parameters:
selected - the newly selected object

computeNewContents

public void computeNewContents(java.lang.Object superSelected)
Compute the new Contents based on the new object selected in the super model. This implementation just removes any items in this combo box and is meant to be overridden by extending classes! This method is invoked each time the selected item in the super model changes to a truly new value.

Parameters:
superSelected - the newly selected object of the super model

getSuperSelected

public java.lang.Object getSuperSelected()
Getter for property superSelected.

Returns:
Value of property superSelected.


Copyright © Tilmann Kuhn