|
Quaqua 8.0 2011-10-02 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.plaf.ComponentUI
javax.swing.plaf.SpinnerUI
javax.swing.plaf.basic.BasicSpinnerUI
ch.randelshofer.quaqua.QuaquaSpinnerUI
public class QuaquaSpinnerUI
QuaquaSpinnerUI.
Field Summary |
---|
Fields inherited from class javax.swing.plaf.basic.BasicSpinnerUI |
---|
spinner |
Fields inherited from interface ch.randelshofer.quaqua.VisuallyLayoutable |
---|
CLIP_BOUNDS, COMPONENT_BOUNDS, TEXT_BOUNDS |
Constructor Summary | |
---|---|
QuaquaSpinnerUI()
|
Method Summary | |
---|---|
protected javax.swing.JComponent |
createEditor()
This method is called by installUI to get the editor component of the JSpinner . |
protected java.awt.LayoutManager |
createLayout()
Create a LayoutManager that manages the editor ,
nextButton , and previousButton
children of the JSpinner. |
protected java.awt.Component |
createNextButton()
Create a component that will replace the spinner models value with the object returned by spinner.getNextValue . |
protected java.awt.Component |
createPreviousButton()
Create a component that will replace the spinner models value with the object returned by spinner.getPreviousValue . |
protected java.beans.PropertyChangeListener |
createPropertyChangeListener()
Create a PropertyChangeListener that can be
added to the JSpinner itself. |
static javax.swing.plaf.ComponentUI |
createUI(javax.swing.JComponent c)
|
int |
getBaseline(javax.swing.JComponent c,
int width,
int height)
Returns the baseline for the specified component, or -1 if the baseline can not be determined. |
protected java.awt.Insets |
getMargin()
|
java.awt.Rectangle |
getVisualBounds(javax.swing.JComponent c,
int layoutType,
int width,
int height)
Returns the visual bounds for the specified component, or null if the visual bounds can not be determined. |
protected void |
installListeners()
Initializes propertyChangeListener with
a shared object that delegates interesting PropertyChangeEvents
to protected methods. |
void |
installUI(javax.swing.JComponent c)
Calls installDefaults , installListeners ,
and then adds the components returned by createNextButton ,
createPreviousButton , and createEditor . |
void |
paint(java.awt.Graphics g,
javax.swing.JComponent c)
|
protected void |
replaceEditor(javax.swing.JComponent oldEditor,
javax.swing.JComponent newEditor)
Called by the PropertyChangeListener when the
JSpinner editor property changes. |
protected void |
uninstallListeners()
Removes the propertyChangeListener added
by installListeners. |
Methods inherited from class javax.swing.plaf.basic.BasicSpinnerUI |
---|
getBaselineResizeBehavior, installDefaults, installKeyboardActions, installNextButtonListeners, installPreviousButtonListeners, uninstallDefaults, uninstallUI |
Methods inherited from class javax.swing.plaf.ComponentUI |
---|
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, update |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public QuaquaSpinnerUI()
Method Detail |
---|
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
protected java.awt.Component createPreviousButton()
spinner.getPreviousValue
.
By default the previousButton
is a JButton
who's ActionListener
updates it's JSpinner
ancestors model. If a previousButton isn't needed (in a subclass)
then override this method to return null.
createPreviousButton
in class javax.swing.plaf.basic.BasicSpinnerUI
installUI(javax.swing.JComponent)
,
createNextButton()
protected java.awt.Component createNextButton()
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.
createNextButton
in class javax.swing.plaf.basic.BasicSpinnerUI
installUI(javax.swing.JComponent)
,
createPreviousButton()
protected java.awt.LayoutManager createLayout()
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.
createLayout
in class javax.swing.plaf.basic.BasicSpinnerUI
createNextButton()
,
createPreviousButton()
,
createEditor()
protected java.beans.PropertyChangeListener createPropertyChangeListener()
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
.
createPropertyChangeListener
in class javax.swing.plaf.basic.BasicSpinnerUI
installListeners()
protected javax.swing.JComponent createEditor()
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.
createEditor
in class javax.swing.plaf.basic.BasicSpinnerUI
installUI(javax.swing.JComponent)
,
replaceEditor(javax.swing.JComponent, javax.swing.JComponent)
,
JSpinner.getEditor()
protected void replaceEditor(javax.swing.JComponent oldEditor, javax.swing.JComponent newEditor)
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.
replaceEditor
in class javax.swing.plaf.basic.BasicSpinnerUI
createEditor()
,
createPropertyChangeListener()
public void paint(java.awt.Graphics g, javax.swing.JComponent c)
paint
in class javax.swing.plaf.ComponentUI
public void installUI(javax.swing.JComponent c)
installDefaults
, installListeners
,
and then adds the components returned by createNextButton
,
createPreviousButton
, and createEditor
.
installUI
in class javax.swing.plaf.basic.BasicSpinnerUI
c
- the JSpinnerBasicSpinnerUI.installDefaults()
,
installListeners()
,
createNextButton()
,
createPreviousButton()
,
createEditor()
protected void installListeners()
propertyChangeListener
with
a shared object that delegates interesting PropertyChangeEvents
to protected methods.
This method is called by installUI
.
installListeners
in class javax.swing.plaf.basic.BasicSpinnerUI
replaceEditor(javax.swing.JComponent, javax.swing.JComponent)
,
uninstallListeners()
protected void uninstallListeners()
propertyChangeListener
added
by installListeners.
This method is called by uninstallUI
.
uninstallListeners
in class javax.swing.plaf.basic.BasicSpinnerUI
installListeners()
protected java.awt.Insets getMargin()
public int getBaseline(javax.swing.JComponent c, int width, int height)
VisuallyLayoutable
getBaseline
in interface VisuallyLayoutable
getBaseline
in class javax.swing.plaf.basic.BasicSpinnerUI
c
- JComponent to calculate baseline forwidth
- Width of the component to determine baseline for.height
- Height of the component to determine baseline for.
public java.awt.Rectangle getVisualBounds(javax.swing.JComponent c, int layoutType, int width, int height)
VisuallyLayoutable
getVisualBounds
in interface VisuallyLayoutable
c
- JComponent to calculate visual margin forlayoutType
- The type of the visual margin.width
- Width of the componentheight
- Height of the component
|
Copyright 2003-2007 (c) Werner Randelshofer. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |