Spinners
You might be wondering just what a spinner is. It’s a new
1.4 component similar to the JComboBox, but it shows only one item. It
includes up and down arrows to "scroll” through its set of values. A JFormattedTextField is used to edit and render those values. Spinners are
quite flexible. They work nicely with a set of choices (such as the
months of the year) as well as with unbounded ranges such as a set of
integers. Figure 7-13 shows
several examples of spinners in different L&Fs. The Mac L&F is missing from this figure
because the SDK 1.4 was not available on OS X at the time we went to
press.

Figure 7-13. Various JSpinner instances in three L&Fs
The classes involved in spinners are shown in Figure 7-14.

Figure 7-14. JSpinner class diagram
Properties
JSpinner has several properties related to the values it
displays (see Table
7-16). Most of the properties are easy to understand from their
names alone. The currently selected value is available through the
read/write value property.
Table 7-16. JSpinner properties
Property | Data type | get | is | set | Default value |
|---|---|---|---|---|---|
changeListeners | ChangeListener[] | · | Empty array | ||
editorb | JComponent | · | · | JPspinner.NumberEditor( ) | |
modelb | SpinnerModel | · | · | SpinnerNumberModel( ) | |
nextValue | Object | · | |||
previousValue | Object | · | |||
UI | SpinnerUI | · | L&F-dependent | ||
UIClassID | String | · | “SpinnerUI” ... |