Java Reference
In-Depth Information
If the minimum or maximum value is null , the range is open-ended. For the no-argument
version, the initial value is 0 and step is 1. The step size is literal, so if you set the step to .333,
there will be no rounding off.
Table 14-5 shows the properties for SpinnerNumberModel . The added properties are the
same as those provided by the constructor.
Table 14-5. SpinnerNumberModel Properties
Property Name
Data Type
Access
maximum
Comparable
Read-write
minimum
Comparable
Read-write
nextValue
Object
Read-only
number
Number
Read-only
previousValue
Object
Read-only
stepSize
Number
Read-write
value
Object
Read-write
Custom Models
Typically, the available models for the JSpinner are sufficient, so you don't need to subclass.
However, that isn't always the case. For example, you might want to use a custom model that
wraps the SpinnerListModel —instead of stopping at the first or last element, it wraps around to
the other end. One such implementation is shown in Listing 14-2.
Listing 14-2. RolloverSpinnerListModel Class
import javax.swing.*;
import java.util.*;
public class RolloverSpinnerListModel extends SpinnerListModel {
public RolloverSpinnerListModel(List<?> values) {
super(values);
}
public RolloverSpinnerListModel(Object[] values) {
super(values);
}
Search WWH ::




Custom Search