Java Reference
In-Depth Information
public Object getNextValue() {
Object returnValue = super.getNextValue();
if (returnValue == null) {
returnValue = getList().get(0);
}
return returnValue;
}
public Object getPreviousValue() {
Object returnValue = super.getPreviousValue();
if (returnValue == null) {
List list = getList();
returnValue = list.get(list.size() - 1);
}
return returnValue;
}
}
JSpinner Editors
For each of the models available for a JSpinner , a secondary support class, an inner class of
JSpinner , is available. Whereas the model allows you to control what is selectable for the
component, the spinner editors allow you to control how to display and edit each selectable value.
JSpinner.DefaultEditor Class
The setEditor() method of JSpinner allows you to have any JComponent as the editor for the
JSpinner . While you certainly can do that, more typically, you will work with a subclass of
JSpinner.DefaultEditor . It provides the basics you will need when working with simple editors
based on JFormattedTextField . It contains a single constructor:
public JSpinner.DefaultEditor(JSpinner spinner)
JSpinner spinner = new JSpinner();
JComponent editor = JSpinner.DefaultEditor(spinner);
spinner.setEditor(editor);
As Table 14-6 shows, there are two properties for the editor.
Table 14-6. JSpinner.DefaultEditor Properties
Property Name
Data Type
Access
spinner
JSpinner
Read-only
textField
JFormattedTextField
Read-only
Search WWH ::




Custom Search