Java Reference
In-Depth Information
Table 14-2.
JSpinner UIResource Elements
Property String
Object Type
Spinner.actionMap
ActionMap
Spinner.ancestorInputMap
InputMap
Spinner.arrowButtonBorder
Border
Spinner.arrowButtonInsets
Insets
Spinner.arrowButtonSize
Dimension
Spinner.background
Color
Spinner.border
Border
Spinner.editorBorderPainted
Boolean
Spinner.font
Font
Spinner.foreground
Color
SpinnerUI
String
SpinnerModel Interface
So far, you've seen how to interact with the main
JSpinner
class. The
SpinnerModel
interface is
the data model for the component. The definition of
SpinnerModel
follows:
public interface SpinnerModel {
// Properties
public Object getValue();
public void setValue(Object);
public Object getNextValue();
public Object getPreviousValue();
// Listeners
public void addChangeListener(ChangeListener);
public void removeChangeListener(ChangeListener);
}
The six methods of
SpinnerModel
map directly to those of
JSpinner
. The
JSpinner
methods
just redirect the method calls to that of the model, though in the case of the listener methods,
the event source is where you attach the listener.
AbstractSpinnerModel Class
The base implementation of the
SpinnerModel
interface is the
AbstractSpinnerModel
class. It
provides for the management and notification of the listener list. Subclasses must implement
the other four value-related methods of the interface. Three concrete implementations
of the
SpinnerModel
interface are provided:
SpinnerDateModel
,
SpinnerListModel
, and
SpinnerNumberModel
.