java.lang.Object | |||
↳ | javax.swing.plaf.ComponentUI | ||
↳ | javax.swing.plaf.SpinnerUI | ||
↳ | javax.swing.plaf.basic.BasicSpinnerUI |
![]() |
The default Spinner UI delegate.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
spinner | The spinner that we're a UI delegate for. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a new instance of BasicSpinnerUI.
| |||||||||||
Returns the baseline.
| |||||||||||
Returns an enum indicating how the baseline of the component
changes as the size changes.
| |||||||||||
Calls
installDefaults , installListeners ,
and then adds the components returned by createNextButton ,
createPreviousButton , and createEditor . | |||||||||||
Calls
uninstallDefaults , uninstallListeners ,
and then removes all of the spinners children. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This method is called by installUI to get the editor component
of the
JSpinner . | |||||||||||
Create a
LayoutManager that manages the editor ,
nextButton , and previousButton
children of the JSpinner. | |||||||||||
Create a component that will replace the spinner models value
with the object returned by
spinner.getNextValue . | |||||||||||
Create a component that will replace the spinner models value
with the object returned by
spinner.getPreviousValue . | |||||||||||
Create a
PropertyChangeListener that can be
added to the JSpinner itself. | |||||||||||
Initialize the
JSpinner border ,
foreground , and background , properties
based on the corresponding "Spinner.*" properties from defaults table. | |||||||||||
Installs the keyboard Actions onto the JSpinner.
| |||||||||||
Initializes
PropertyChangeListener with
a shared object that delegates interesting PropertyChangeEvents
to protected methods. | |||||||||||
Installs the necessary listeners on the next button,
c ,
to update the JSpinner in response to a user gesture. | |||||||||||
Installs the necessary listeners on the previous button,
c ,
to update the JSpinner in response to a user gesture. | |||||||||||
Called by the
PropertyChangeListener when the
JSpinner editor property changes. | |||||||||||
Sets the
JSpinner's layout manager to null. | |||||||||||
Removes the
PropertyChangeListener added
by installListeners. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
The spinner that we're a UI delegate for. Initialized by
the installUI
method, and reset to null
by uninstallUI
.
Returns a new instance of BasicSpinnerUI. SpinnerListUI delegates are allocated one per JSpinner.
c | the JSpinner (not used) |
---|
Returns the baseline.
c | JComponent baseline is being requested for |
---|---|
width | the width to get the baseline for |
height | the height to get the baseline for |
Returns an enum indicating how the baseline of the component changes as the size changes.
c | JComponent to return baseline resize behavior for |
---|
NullPointerException |
---|
Calls installDefaults
, installListeners
,
and then adds the components returned by createNextButton
,
createPreviousButton
, and createEditor
.
c | the JSpinner |
---|
Calls uninstallDefaults
, uninstallListeners
,
and then removes all of the spinners children.
c | the JSpinner (not used) |
---|
This method is called by installUI to get the editor component
of the JSpinner
. By default it just returns
JSpinner.getEditor()
. Subclasses can override
createEditor
to return a component that contains
the spinner's editor or null, if they're going to handle adding
the editor to the JSpinner
in an
installUI
override.
Typically this method would be overridden to wrap the editor with a container with a custom border, since one can't assume that the editors border can be set directly.
The replaceEditor
method is called when the spinners
editor is changed with JSpinner.setEditor
. If you've
overriden this method, then you'll probably want to override
replaceEditor
as well.
Create a LayoutManager
that manages the editor
,
nextButton
, and previousButton
children of the JSpinner. These three children must be
added with a constraint that identifies their role:
"Editor", "Next", and "Previous". The default layout manager
can handle the absence of any of these children.
Create a component that will replace the spinner models value
with the object returned by spinner.getNextValue
.
By default the nextButton
is a JButton
who's ActionListener
updates it's JSpinner
ancestors model. If a nextButton isn't needed (in a subclass)
then override this method to return null.
Create a component that will replace the spinner models value
with the object returned by spinner.getPreviousValue
.
By default the previousButton
is a JButton. This
method invokes installPreviousButtonListeners
to
install the necessary listeners to update the JSpinner
's
model in response to a user gesture. If a previousButton isn't needed
(in a subclass) then override this method to return null.
Create a PropertyChangeListener
that can be
added to the JSpinner itself. Typically, this listener
will call replaceEditor when the "editor" property changes,
since it's the SpinnerUI's
responsibility to
add the editor to the JSpinner (and remove the old one).
This method is called by installListeners
.
Initialize the JSpinner
border
,
foreground
, and background
, properties
based on the corresponding "Spinner.*" properties from defaults table.
The JSpinners
layout is set to the value returned by
createLayout
. This method is called by installUI
.
Installs the keyboard Actions onto the JSpinner.
Initializes PropertyChangeListener
with
a shared object that delegates interesting PropertyChangeEvents
to protected methods.
This method is called by installUI
.
Installs the necessary listeners on the next button, c
,
to update the JSpinner
in response to a user gesture.
c | Component to install the listeners on |
---|
NullPointerException | if c is null. |
---|
Installs the necessary listeners on the previous button, c
,
to update the JSpinner
in response to a user gesture.
c | Component to install the listeners on. |
---|
NullPointerException | if c is null. |
---|
Called by the PropertyChangeListener
when the
JSpinner
editor property changes. It's the responsibility
of this method to remove the old editor and add the new one. By
default this operation is just:
spinner.remove(oldEditor); spinner.add(newEditor, "Editor");The implementation of
replaceEditor
should be coordinated
with the createEditor
method.Sets the JSpinner's
layout manager to null. This
method is called by uninstallUI
.
Removes the PropertyChangeListener
added
by installListeners.
This method is called by uninstallUI
.