This is a pretty much a direct copy of the SpinnerListModel from JDK 1.5 sources.
It was copied out in order to expose methods that needed to be publicly available
in order to allow for completion to work properly with a list of complex objects
that present their human readable value from a toString(). The findNextMatch
method was exposed as public.
Constructor Summary
public
EnhancedSpinnerListModel(List> values) Constructs a SpinnerModel whose sequence of
values is defined by the specified List.
public
EnhancedSpinnerListModel(Object[] values) Constructs a SpinnerModel whose sequence of values
is defined by the specified array.
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.
public void
setValue(Object elt) Changes the current element of the sequence and notifies
ChangeListeners.
Constructor Detail
EnhancedSpinnerListModel
public EnhancedSpinnerListModel(List> values)(Code)
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 isnull or zero size
EnhancedSpinnerListModel
public EnhancedSpinnerListModel(Object[] values)(Code)
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 isnull or zero length
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.
Parameters: list - the sequence that this model represents throws: IllegalArgumentException - if list isnull or zero length See Also:EnhancedSpinnerListModel.getList
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");