Java Reference
In-Depth Information
■
Note
The
SpinnerDateModel
does not include any of the time zone-related constants of
Calendar
.
You cannot scroll through those within a
JSpinner
via a
SpinnerDateModel
.
Table 14-3 lists the three properties from the
SpinnerModel
interface and four specific to
the
SpinnerDateModel
.
Table 14-3.
SpinnerDateModel Properties
Property Name
Data Type
Access
calendarField
int
Read-write
date
Date
Read-only
end
Comparable
Read-write
nextValue
Object
Read-only
previousValue
Object
Read-only
start
Comparable
Read-write
value
Object
Read-only
Typically, the only new property you'll use is for getting the final date, although all that
does is wrap the result of
getValue()
in the appropriate data type. If you've provided a range of
dates to the constructor, the previous or next values will be
null
when the current value is at an
edge condition.
SpinnerListModel Class
The
SpinnerListModel
provides for selection from a list of entries, or at least their string repre-
sentation. This class has three constructors:
public SpinnerListModel()
SpinnerModel model = new SpinnerListModel();
JSpinner spinner = new JSpinner(model);
public SpinnerListModel(List<?> values)
List<String> list = args;
SpinnerModel model = new SpinnerListModel(list);
JSpinner spinner = new JSpinner(model);
public SpinnerListModel(Object[] values)
SpinnerModel model = new SpinnerListModel(args);
JSpinner spinner = new JSpinner(model);