|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JSpinner
public class JSpinner
A 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.
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 JSpinner component. |
static class |
JSpinner.ListEditor
A JSpinner editor used for the SpinnerListModel . |
static class |
JSpinner.NumberEditor
A panel containing a JFormattedTextField that is configured for
displaying and editing numbers. |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JSpinner()
Creates a new JSpinner with default instance of
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 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JSpinner()
JSpinner
with default instance of
SpinnerNumberModel
(that is, a model with value 0, step size 1,
and no upper or lower limit).
SpinnerNumberModel
public JSpinner(SpinnerModel model)
JSpinner with the specified model. The
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
.
Method Detail |
---|
public void commitEdit() throws ParseException
JSpinner.DefaultEditor
, then forwards the
call to it, otherwise do nothing.
ParseException
- DOCUMENT ME!public JComponent getEditor()
setEditor(javax.swing.JComponent)
public void setEditor(JComponent editor)
ChangeEvent
list.
editor
- the new editor (null
not permitted.
IllegalArgumentException
- if editor
is
null
.getEditor()
public SpinnerModel getModel()
JSpinner
component.
setModel(SpinnerModel)
public void setModel(SpinnerModel newModel)
newModel
- the new model to set
IllegalArgumentException
- if newModel is null
public Object getNextValue()
SpinnerModel.getNextValue()
public Object getPreviousValue()
SpinnerModel.getPreviousValue()
public SpinnerUI getUI()
SpinnerUI
that handles this spinner
SpinnerUI
public Object getValue()
SpinnerModel.getValue()
public void setValue(Object value)
value
- the new value.public String getUIClassID()
getUIClassID
in class JComponent
"SpinnerUI"
.JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void updateUI()
updateUI
in class JComponent
public void setUI(SpinnerUI ui)
ui
- The spinner's UI delegate.public void addChangeListener(ChangeListener listener)
ChangeListener
listener
- the listener to addpublic void removeChangeListener(ChangeListener listener)
listener
- the listener to removepublic ChangeListener[] getChangeListeners()
ChangeListener
s
ChangeListener
sprotected void fireStateChanged()
ChangeEvent
to all the ChangeListener
s
added to this JSpinner
protected JComponent createEditor(SpinnerModel model)
model
.
model
- the model.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |