|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--AbstractSpinnerModel | +--SpinnerListModel
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 ListSpinnerModel(days);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 models value or list
properties changes.
JSpinner,
SpinnerModel,
AbstractSpinnerModel,
SpinnerNumberModel,
SpinnerDateModel| Fields inherited from class AbstractSpinnerModel |
listenerList |
| Constructor Summary | |
SpinnerListModel()
Construct an effectively empty SpinnerListModel. |
|
SpinnerListModel(java.util.List values)
Construct a SpinnerModel whose sequence of values is defined by the specified List. |
|
SpinnerListModel(java.lang.Object[] values)
Construct a SpinnerModel whose sequence of values is
defined by
the specified array. |
|
| Method Summary | |
java.util.List |
getList()
Return the List that defines the sequence for this model. |
java.lang.Object |
getNextValue()
Returns the next legal value of the underlying sequence or null if value is already the last element. |
java.lang.Object |
getPreviousValue()
Returns the previous element of the underlying sequence or null if value is already the first element. |
java.lang.Object |
getValue()
Returns the current element of the sequence. |
void |
setList(java.util.List list)
Changes the list that defines this sequence and resets the index of the models value to zero. |
void |
setValue(java.lang.Object elt)
Changes the current element of the sequence and notifies ChangeListeners. |
| Methods inherited from class AbstractSpinnerModel |
addChangeListener, fireStateChanged, getListeners, removeChangeListener |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public SpinnerListModel(java.util.List values)
List. The intial value (current element)
of the model will be values.get(0). If values
is null or has zero size then an IllegalArugmentException is thrown.values - the sequence this model representsIllegalArugmentException - if values is null or zero sizepublic SpinnerListModel(java.lang.Object[] values)
SpinnerModel whose sequence of values is
defined by
the specified array. The intial value of the model will
be values[0]. If values is null
or has zero length then an IllegalArugmentException is thrown.values - the sequence this model representsIllegalArugmentException - if values is null or zero lengthpublic SpinnerListModel()
SpinnerListModel.
The model's list will contain a single "empty" string element.IllegalArugmentException - if values is null or zero length| Method Detail |
public java.util.List getList()
List that defines the sequence for this model.list propertysetList(java.util.List)public void setList(java.util.List list)
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.
list - the sequence that this model representsjava.lang.IllegalArgumentException - if list is null or zero lengthgetList()public java.lang.Object getValue()
value propertySpinnerModel.getValue(),
setValue(java.lang.Object)public void setValue(java.lang.Object elt)
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");
elt - the sequence element that will be models current valuejava.lang.IllegalArgumentException - if the specified value isn't allowedSpinnerModel.setValue(java.lang.Object),
getValue()public java.lang.Object getNextValue()
SpinnerModel.getNextValue(),
getPreviousValue()public java.lang.Object getPreviousValue()
SpinnerModel.getPreviousValue(),
getNextValue()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||