javax.swing
public class JSpinner extends JComponent
JSpinner
is a component that displays a single value from
a sequence of values, and provides a convenient means for selecting the
previous and next values in the sequence. Typically the spinner displays
a numeric value, but it is possible to display dates or arbitrary items
from a list.
Since: 1.4
Nested Class Summary | |
---|---|
static class | JSpinner.DateEditor
An editor class for a JSpinner that is used
for displaying and editing dates (e.g. that uses
SpinnerDateModel as model).
|
static class | JSpinner.DefaultEditor
The base class for the editor used by the {@link JSpinner} component.
|
static class | JSpinner.ListEditor
A JSpinner editor used for the {@link SpinnerListModel}.
|
static class | JSpinner.NumberEditor
A panel containing a {@link JFormattedTextField} that is configured for
displaying and editing numbers. |
Constructor Summary | |
---|---|
JSpinner()
Creates a new JSpinner with default instance of
{@link SpinnerNumberModel} (that is, a model with value 0, step size 1,
and no upper or lower limit).
| |
JSpinner(SpinnerModel model)
Creates a new JSpinner with the specified model. |
Method Summary | |
---|---|
void | addChangeListener(ChangeListener listener)
Adds a ChangeListener
|
void | commitEdit()
If the editor is JSpinner.DefaultEditor , then forwards the
call to it, otherwise do nothing.
|
protected JComponent | createEditor(SpinnerModel model)
Creates an editor that is appropriate for the specified model .
|
protected void | fireStateChanged()
Fires a ChangeEvent to all the ChangeListener s
added to this JSpinner |
ChangeListener[] | getChangeListeners()
Gets all the ChangeListener s
|
JComponent | getEditor()
Gets the current editor
|
SpinnerModel | getModel()
Returns the model used by the {@link JSpinner} component.
|
Object | getNextValue()
Gets the next value without changing the current value.
|
Object | getPreviousValue()
Gets the previous value without changing the current value.
|
SpinnerUI | getUI()
Gets the SpinnerUI that handles this spinner
|
String | getUIClassID()
Returns the ID that identifies which look and feel class will be
the UI delegate for this spinner.
|
Object | getValue()
Gets the current value of the spinner, according to the underly model,
not the UI.
|
void | removeChangeListener(ChangeListener listener)
Remove a particular listener
|
void | setEditor(JComponent editor)
Changes the current editor to the new editor. |
void | setModel(SpinnerModel newModel)
Sets a new underlying model.
|
void | setUI(SpinnerUI ui)
Sets the UI delegate for the component.
|
void | setValue(Object value)
Sets the value in the model.
|
void | updateUI()
This method resets the spinner's UI delegate to the default UI for the
current look and feel. |
JSpinner
with default instance of
{@link SpinnerNumberModel} (that is, a model with value 0, step size 1,
and no upper or lower limit).
See Also: SpinnerNumberModel
JSpinner with the specified model. The
{@link #createEditor(SpinnerModel)} method is used to create an editor
that is suitable for the model.
Parameters: model the model (null
not permitted).
Throws: NullPointerException if model
is null
.
ChangeListener
Parameters: listener the listener to add
JSpinner.DefaultEditor
, then forwards the
call to it, otherwise do nothing.
Throws: ParseException DOCUMENT ME!
model
.
Parameters: model the model.
Returns: The editor.
ChangeEvent
to all the ChangeListener
s
added to this JSpinner
ChangeListener
s
Returns: all the ChangeListener
s
Returns: the current editor
See Also: JSpinner
Returns: The model.
See Also: setModel
Returns: the next value
See Also: SpinnerModel
Returns: the previous value
See Also: SpinnerModel
SpinnerUI
that handles this spinner
Returns: the SpinnerUI
Returns: "SpinnerUI"
.
Returns: the current value
See Also: SpinnerModel
Parameters: listener the listener to remove
Parameters: editor the new editor (null
not permitted.
Throws: IllegalArgumentException if editor
is
null
.
See Also: JSpinner
Parameters: newModel the new model to set
Throws: IllegalArgumentException if newModel is null
Parameters: ui The spinner's UI delegate.
Parameters: value the new value.