Methods Summary |
---|
protected javax.swing.JComponent | createEditor()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.
JComponent editor = spinner.getEditor();
editor.setName("Spinner.editor");
return editor;
|
protected java.awt.LayoutManager | createLayout()
return new SpinnerLayout();
|
protected java.awt.Component | createNextButton()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.
JButton b = new SynthArrowButton(SwingConstants.NORTH);
b.setName("Spinner.nextButton");
installNextButtonListeners(b);
return b;
|
protected java.awt.Component | createPreviousButton()Create a component that will replace the spinner models value
with the object returned by 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.
JButton b = new SynthArrowButton(SwingConstants.SOUTH);
b.setName("Spinner.previousButton");
installPreviousButtonListeners(b);
return b;
|
protected java.beans.PropertyChangeListener | createPropertyChangeListener()
return this;
|
public static javax.swing.plaf.ComponentUI | createUI(javax.swing.JComponent c)Returns a new instance of SynthSpinnerUI.
return new SynthSpinnerUI();
|
private int | getComponentState(javax.swing.JComponent c)
return SynthLookAndFeel.getComponentState(c);
|
public javax.swing.plaf.synth.SynthContext | getContext(javax.swing.JComponent c)
return getContext(c, getComponentState(c));
|
private javax.swing.plaf.synth.SynthContext | getContext(javax.swing.JComponent c, int state)
return SynthContext.getContext(SynthContext.class, c,
SynthLookAndFeel.getRegion(c), style, state);
|
private javax.swing.plaf.synth.Region | getRegion(javax.swing.JComponent c)
return SynthLookAndFeel.getRegion(c);
|
protected void | installDefaults()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 .
LayoutManager layout = spinner.getLayout();
if (layout == null || layout instanceof UIResource) {
spinner.setLayout(createLayout());
}
updateStyle(spinner);
|
protected void | installListeners()
spinner.addPropertyChangeListener(this);
|
public void | paint(java.awt.Graphics g, javax.swing.JComponent c)
SynthContext context = getContext(c);
paint(context, g);
context.dispose();
|
protected void | paint(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g)
|
public void | paintBorder(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g, int x, int y, int w, int h)
context.getPainter().paintSpinnerBorder(context, g, x, y, w, h);
|
public void | propertyChange(java.beans.PropertyChangeEvent e)
String propertyName = e.getPropertyName();
JSpinner spinner = (JSpinner)(e.getSource());
SpinnerUI spinnerUI = spinner.getUI();
if (spinnerUI instanceof SynthSpinnerUI) {
SynthSpinnerUI ui = (SynthSpinnerUI)spinnerUI;
if (SynthLookAndFeel.shouldUpdateStyle(e)) {
ui.updateStyle(spinner);
}
if ("editor".equals(propertyName)) {
JComponent oldEditor = (JComponent)e.getOldValue();
JComponent newEditor = (JComponent)e.getNewValue();
ui.replaceEditor(oldEditor, newEditor);
ui.updateEnabledState();
}
else if ("enabled".equals(propertyName)) {
ui.updateEnabledState();
}
}
|
protected void | replaceEditor(javax.swing.JComponent oldEditor, javax.swing.JComponent newEditor)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.
spinner.remove(oldEditor);
spinner.add(newEditor, "Editor");
|
protected void | uninstallDefaults()Sets the JSpinner's layout manager to null. This
method is called by uninstallUI .
if (spinner.getLayout() instanceof UIResource) {
spinner.setLayout(null);
}
SynthContext context = getContext(spinner, ENABLED);
style.uninstallDefaults(context);
context.dispose();
style = null;
|
protected void | uninstallListeners()Removes the propertyChangeListener added
by installListeners.
This method is called by uninstallUI .
spinner.removePropertyChangeListener(this);
|
public void | update(java.awt.Graphics g, javax.swing.JComponent c)
SynthContext context = getContext(c);
SynthLookAndFeel.update(context, g);
context.getPainter().paintSpinnerBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
context.dispose();
|
private void | updateEnabledState()Updates the enabled state of the children Components based on the
enabled state of the JSpinner .
updateEnabledState(spinner, spinner.isEnabled());
|
private void | updateEnabledState(java.awt.Container c, boolean enabled)Recursively updates the enabled state of the child
Component s of c .
for (int counter = c.getComponentCount() - 1; counter >= 0;counter--) {
Component child = c.getComponent(counter);
child.setEnabled(enabled);
if (child instanceof Container) {
updateEnabledState((Container)child, enabled);
}
}
|
private void | updateStyle(javax.swing.JSpinner c)
SynthContext context = getContext(c, ENABLED);
SynthStyle oldStyle = style;
style = SynthLookAndFeel.updateStyle(context, this);
if (style != oldStyle) {
if (oldStyle != null) {
// Only call installKeyboardActions as uninstall is not
// public.
installKeyboardActions();
}
}
context.dispose();
|