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.
JSpinner, SpinnerModel, AbstractSpinnerModel, SpinnerNumberModel, SpinnerDateModel
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private List |
| Access | Constructor and Description |
|---|---|
| public | SpinnerListModel(List<?>
the sequence this model represents values)Constructs a |
| public | SpinnerListModel(Object[]
the sequence this model represents values)Constructs a |
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv Object | Returns: the matchthe string to be matched substring)Returns the next object that starts with |
| public List | Returns: the value of thelist propertyReturns the |
| public Object | Returns: the next legal value of the underlying sequence ornull if value is already the last elementImplements javax. Returns the next legal value of the underlying sequence or
|
| public Object | Returns: the previous element of the underlying sequence ornull if value is already the first elementImplements javax. Returns the previous element of the underlying sequence or
|
| public Object | Returns: thevalue propertyImplements javax. Returns the current element of the sequence. |
| public void | |
| public void | setValue(Object
the sequence element that will be model's current value elt)Implements javax. Changes the current element of the sequence and notifies
|
| SpinnerListModel | back to summary |
|---|---|
| public SpinnerListModel(List<?> values) Constructs a
| |
| SpinnerListModel | back to summary |
|---|---|
| public SpinnerListModel(Object[] values) Constructs a
| |
| SpinnerListModel | back to summary |
|---|---|
| public SpinnerListModel() Constructs an effectively empty | |
| findNextMatch | back to summary |
|---|---|
| pack-priv Object findNextMatch(String substring) Returns the next object that starts with | |
| getList | back to summary |
|---|---|
| public List Returns the | |
| getNextValue | back to summary |
|---|---|
| public Object getNextValue() Implements javax. Returns the next legal value of the underlying sequence or
| |
| getPreviousValue | back to summary |
|---|---|
| public Object getPreviousValue() Implements javax. Returns the previous element of the underlying sequence or
| |
| getValue | back to summary |
|---|---|
| public Object getValue() Implements javax. Returns the current element of the sequence.
| |
| setList | back to summary |
|---|---|
| public void setList(List<?> list) Changes the list that defines this sequence and resets the index
of the models
This method fires a
| |
| setValue | back to summary |
|---|---|
| public void setValue(Object elt) Implements javax. Changes the current element of the sequence and notifies
String[] values = {"one", "two", "free", "four"};
SpinnerModel model = new SpinnerListModel(values);
model.setValue("TWO");
| |