Home » openjdk-7 » javax » swing » [javadoc | source]
javax.swing
public class: SpinnerListModel [javadoc | source]
java.lang.Object
   javax.swing.AbstractSpinnerModel
      javax.swing.SpinnerListModel

All Implemented Interfaces:
    Serializable, SpinnerModel

A simple implementation of SpinnerModel whose values are defined by an array or a List. For example to create a model defined by an array of the names of the days of the week:
String[] days = new DateFormatSymbols().getWeekdays();
SpinnerModel model = new SpinnerListModel(Arrays.asList(days).subList(1, 8));
This class only stores a reference to the array or List so if an element of the underlying sequence changes, it's up to the application to notify the ChangeListeners by calling fireStateChanged.

This model inherits a ChangeListener. The ChangeListeners are notified whenever the model's value or list properties changes.

Fields inherited from javax.swing.AbstractSpinnerModel:
listenerList
Constructor:
 public SpinnerListModel() 
 public SpinnerListModel(List<?> values) 
    Constructs a SpinnerModel whose sequence of values is defined by the specified List. The initial value (current element) of the model will be values.get(0). If values is null or has zero size, an IllegalArugmentException is thrown.
    Parameters:
    values - the sequence this model represents
    Throws:
    IllegalArugmentException - if values is null or zero size
 public SpinnerListModel(Object[] values) 
    Constructs a SpinnerModel whose sequence of values is defined by the specified array. The initial value of the model will be values[0]. If values is null or has zero length, an IllegalArugmentException is thrown.
    Parameters:
    values - the sequence this model represents
    Throws:
    IllegalArugmentException - if values is null or zero length
Method from javax.swing.SpinnerListModel Summary:
findNextMatch,   getList,   getNextValue,   getPreviousValue,   getValue,   setList,   setValue
Methods from javax.swing.AbstractSpinnerModel:
addChangeListener,   fireStateChanged,   getChangeListeners,   getListeners,   removeChangeListener
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.SpinnerListModel Detail:
 Object findNextMatch(String substring) 
    Returns the next object that starts with substring.
 public List<?> getList() 
    Returns the List that defines the sequence for this model.
 public Object getNextValue() 
    Returns the next legal value of the underlying sequence or null if value is already the last element.
 public Object getPreviousValue() 
    Returns the previous element of the underlying sequence or null if value is already the first element.
 public Object getValue() 
    Returns the current element of the sequence.
 public  void setList(List<?> list) 
    Changes the list that defines this sequence and resets the index of the models value to zero. Note that list is not copied, the model just stores a reference to it.

    This method fires a ChangeEvent if list is not equal to the current list.

 public  void setValue(Object elt) 
    Changes the current element of the sequence and notifies ChangeListeners. If the specified value is not equal to an element of the underlying sequence then an IllegalArgumentException is thrown. In the following example the setValue call would cause an exception to be thrown:
    String[] values = {"one", "two", "free", "four"};
    SpinnerModel model = new SpinnerListModel(values);
    model.setValue("TWO");