< prev index next >
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java
Print this page
*** 49,60 ****
*/
public class BasicSpinnerUI extends SpinnerUI
{
/**
* The spinner that we're a UI delegate for. Initialized by
! * the <code>installUI</code> method, and reset to null
! * by <code>uninstallUI</code>.
*
* @see #installUI
* @see #uninstallUI
*/
protected JSpinner spinner;
--- 49,60 ----
*/
public class BasicSpinnerUI extends SpinnerUI
{
/**
* The spinner that we're a UI delegate for. Initialized by
! * the {@code installUI} method, and reset to null
! * by {@code uninstallUI}.
*
* @see #installUI
* @see #uninstallUI
*/
protected JSpinner spinner;
*** 100,112 ****
}
}
/**
! * Calls <code>installDefaults</code>, <code>installListeners</code>,
! * and then adds the components returned by <code>createNextButton</code>,
! * <code>createPreviousButton</code>, and <code>createEditor</code>.
*
* @param c the JSpinner
* @see #installDefaults
* @see #installListeners
* @see #createNextButton
--- 100,112 ----
}
}
/**
! * Calls {@code installDefaults}, {@code installListeners},
! * and then adds the components returned by {@code createNextButton},
! * {@code createPreviousButton}, and {@code createEditor}.
*
* @param c the JSpinner
* @see #installDefaults
* @see #installListeners
* @see #createNextButton
*** 124,134 ****
installKeyboardActions();
}
/**
! * Calls <code>uninstallDefaults</code>, <code>uninstallListeners</code>,
* and then removes all of the spinners children.
*
* @param c the JSpinner (not used)
*/
public void uninstallUI(JComponent c) {
--- 124,134 ----
installKeyboardActions();
}
/**
! * Calls {@code uninstallDefaults}, {@code uninstallListeners},
* and then removes all of the spinners children.
*
* @param c the JSpinner (not used)
*/
public void uninstallUI(JComponent c) {
*** 138,152 ****
c.removeAll();
}
/**
! * Initializes <code>PropertyChangeListener</code> with
* a shared object that delegates interesting PropertyChangeEvents
* to protected methods.
* <p>
! * This method is called by <code>installUI</code>.
*
* @see #replaceEditor
* @see #uninstallListeners
*/
protected void installListeners() {
--- 138,152 ----
c.removeAll();
}
/**
! * Initializes {@code PropertyChangeListener} with
* a shared object that delegates interesting PropertyChangeEvents
* to protected methods.
* <p>
! * This method is called by {@code installUI}.
*
* @see #replaceEditor
* @see #uninstallListeners
*/
protected void installListeners() {
*** 166,179 ****
}
}
/**
! * Removes the <code>PropertyChangeListener</code> added
* by installListeners.
* <p>
! * This method is called by <code>uninstallUI</code>.
*
* @see #installListeners
*/
protected void uninstallListeners() {
spinner.removePropertyChangeListener(propertyChangeListener);
--- 166,179 ----
}
}
/**
! * Removes the {@code PropertyChangeListener} added
* by installListeners.
* <p>
! * This method is called by {@code uninstallUI}.
*
* @see #installListeners
*/
protected void uninstallListeners() {
spinner.removePropertyChangeListener(propertyChangeListener);
*** 191,205 ****
handler = null;
}
/**
! * Initialize the <code>JSpinner</code> <code>border</code>,
! * <code>foreground</code>, and <code>background</code>, properties
* based on the corresponding "Spinner.*" properties from defaults table.
! * The <code>JSpinners</code> layout is set to the value returned by
! * <code>createLayout</code>. This method is called by <code>installUI</code>.
*
* @see #uninstallDefaults
* @see #installUI
* @see #createLayout
* @see LookAndFeel#installBorder
--- 191,205 ----
handler = null;
}
/**
! * Initialize the {@code JSpinner border},
! * {@code foreground}, and {@code background}, properties
* based on the corresponding "Spinner.*" properties from defaults table.
! * The {@code JSpinners} layout is set to the value returned by
! * {@code createLayout}. This method is called by {@code installUI}.
*
* @see #uninstallDefaults
* @see #installUI
* @see #createLayout
* @see LookAndFeel#installBorder
*** 212,223 ****
LookAndFeel.installProperty(spinner, "opaque", Boolean.TRUE);
}
/**
! * Sets the <code>JSpinner's</code> layout manager to null. This
! * method is called by <code>uninstallUI</code>.
*
* @see #installDefaults
* @see #uninstallUI
*/
protected void uninstallDefaults() {
--- 212,223 ----
LookAndFeel.installProperty(spinner, "opaque", Boolean.TRUE);
}
/**
! * Sets the {@code JSpinner's} layout manager to null. This
! * method is called by {@code uninstallUI}.
*
* @see #installDefaults
* @see #uninstallUI
*/
protected void uninstallDefaults() {
*** 232,259 ****
return handler;
}
/**
! * Installs the necessary listeners on the next button, <code>c</code>,
! * to update the <code>JSpinner</code> in response to a user gesture.
*
* @param c Component to install the listeners on
! * @throws NullPointerException if <code>c</code> is null.
* @see #createNextButton
* @since 1.5
*/
protected void installNextButtonListeners(Component c) {
installButtonListeners(c, nextButtonHandler);
}
/**
! * Installs the necessary listeners on the previous button, <code>c</code>,
! * to update the <code>JSpinner</code> in response to a user gesture.
*
* @param c Component to install the listeners on.
! * @throws NullPointerException if <code>c</code> is null.
* @see #createPreviousButton
* @since 1.5
*/
protected void installPreviousButtonListeners(Component c) {
installButtonListeners(c, previousButtonHandler);
--- 232,259 ----
return handler;
}
/**
! * Installs the necessary listeners on the next button, {@code c},
! * to update the {@code JSpinner} in response to a user gesture.
*
* @param c Component to install the listeners on
! * @throws NullPointerException if {@code c} is null.
* @see #createNextButton
* @since 1.5
*/
protected void installNextButtonListeners(Component c) {
installButtonListeners(c, nextButtonHandler);
}
/**
! * Installs the necessary listeners on the previous button, {@code c},
! * to update the {@code JSpinner} in response to a user gesture.
*
* @param c Component to install the listeners on.
! * @throws NullPointerException if {@code c} is null.
* @see #createPreviousButton
* @since 1.5
*/
protected void installPreviousButtonListeners(Component c) {
installButtonListeners(c, previousButtonHandler);
*** 266,277 ****
}
c.addMouseListener(handler);
}
/**
! * Creates a <code>LayoutManager</code> that manages the <code>editor</code>,
! * <code>nextButton</code>, and <code>previousButton</code>
* 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.
*
--- 266,277 ----
}
c.addMouseListener(handler);
}
/**
! * Creates a {@code LayoutManager} that manages the {@code editor},
! * {@code nextButton}, and {@code 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.
*
*** 284,299 ****
return getHandler();
}
/**
! * Creates a <code>PropertyChangeListener</code> that can be
* added to the JSpinner itself. Typically, this listener
* will call replaceEditor when the "editor" property changes,
! * since it's the <code>SpinnerUI's</code> responsibility to
* add the editor to the JSpinner (and remove the old one).
! * This method is called by <code>installListeners</code>.
*
* @return A PropertyChangeListener for the JSpinner itself
* @see #installListeners
*/
protected PropertyChangeListener createPropertyChangeListener() {
--- 284,299 ----
return getHandler();
}
/**
! * Creates a {@code PropertyChangeListener} that can be
* added to the JSpinner itself. Typically, this listener
* will call replaceEditor when the "editor" property changes,
! * since it's the {@code SpinnerUI's} responsibility to
* add the editor to the JSpinner (and remove the old one).
! * This method is called by {@code installListeners}.
*
* @return A PropertyChangeListener for the JSpinner itself
* @see #installListeners
*/
protected PropertyChangeListener createPropertyChangeListener() {
*** 301,312 ****
}
/**
* Creates a decrement button, i.e. component that replaces the spinner
! * value with the object returned by <code>spinner.getPreviousValue</code>.
! * By default the <code>previousButton</code> is a {@code JButton}. If the
* decrement button is not needed this method should return {@code null}.
*
* @return a component that will replace the spinner's value with the
* previous value in the sequence, or {@code null}
* @see #installUI
--- 301,312 ----
}
/**
* Creates a decrement button, i.e. component that replaces the spinner
! * value with the object returned by {@code spinner.getPreviousValue}.
! * By default the {@code previousButton} is a {@code JButton}. If the
* decrement button is not needed this method should return {@code null}.
*
* @return a component that will replace the spinner's value with the
* previous value in the sequence, or {@code null}
* @see #installUI
*** 321,332 ****
}
/**
* Creates an increment button, i.e. component that replaces the spinner
! * value with the object returned by <code>spinner.getNextValue</code>.
! * By default the <code>nextButton</code> is a {@code JButton}. If the
* increment button is not needed this method should return {@code null}.
*
* @return a component that will replace the spinner's value with the
* next value in the sequence, or {@code null}
* @see #installUI
--- 321,332 ----
}
/**
* Creates an increment button, i.e. component that replaces the spinner
! * value with the object returned by {@code spinner.getNextValue}.
! * By default the {@code nextButton} is a {@code JButton}. If the
* increment button is not needed this method should return {@code null}.
*
* @return a component that will replace the spinner's value with the
* next value in the sequence, or {@code null}
* @see #installUI
*** 355,379 ****
}
/**
* This method is called by installUI to get the editor component
! * of the <code>JSpinner</code>. By default it just returns
! * <code>JSpinner.getEditor()</code>. Subclasses can override
! * <code>createEditor</code> to return a component that contains
* the spinner's editor or null, if they're going to handle adding
! * the editor to the <code>JSpinner</code> in an
! * <code>installUI</code> override.
* <p>
* 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.
* <p>
! * The <code>replaceEditor</code> method is called when the spinners
! * editor is changed with <code>JSpinner.setEditor</code>. If you've
* overriden this method, then you'll probably want to override
! * <code>replaceEditor</code> as well.
*
* @return the JSpinners editor JComponent, spinner.getEditor() by default
* @see #installUI
* @see #replaceEditor
* @see JSpinner#getEditor
--- 355,379 ----
}
/**
* This method is called by installUI to get the editor component
! * of the {@code JSpinner}. By default it just returns
! * {@code JSpinner.getEditor()}. Subclasses can override
! * {@code createEditor} to return a component that contains
* the spinner's editor or null, if they're going to handle adding
! * the editor to the {@code JSpinner} in an
! * {@code installUI} override.
* <p>
* 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.
* <p>
! * The {@code replaceEditor} method is called when the spinners
! * editor is changed with {@code JSpinner.setEditor}. If you've
* overriden this method, then you'll probably want to override
! * {@code replaceEditor} as well.
*
* @return the JSpinners editor JComponent, spinner.getEditor() by default
* @see #installUI
* @see #replaceEditor
* @see JSpinner#getEditor
*** 387,406 ****
return editor;
}
/**
! * Called by the <code>PropertyChangeListener</code> when the
! * <code>JSpinner</code> 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:
* <pre>
* spinner.remove(oldEditor);
* spinner.add(newEditor, "Editor");
* </pre>
! * The implementation of <code>replaceEditor</code> should be coordinated
! * with the <code>createEditor</code> method.
*
* @param oldEditor an old instance of editor
* @param newEditor a new instance of editor
* @see #createEditor
* @see #createPropertyChangeListener
--- 387,406 ----
return editor;
}
/**
! * Called by the {@code PropertyChangeListener} when the
! * {@code 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:
* <pre>
* spinner.remove(oldEditor);
* spinner.add(newEditor, "Editor");
* </pre>
! * The implementation of {@code replaceEditor} should be coordinated
! * with the {@code createEditor} method.
*
* @param oldEditor an old instance of editor
* @param newEditor a new instance of editor
* @see #createEditor
* @see #createPropertyChangeListener
*** 475,494 ****
}
/**
* Updates the enabled state of the children Components based on the
! * enabled state of the <code>JSpinner</code>.
*/
private void updateEnabledState() {
updateEnabledState(spinner, spinner.isEnabled());
}
/**
* Recursively updates the enabled state of the child
! * <code>Component</code>s of <code>c</code>.
*/
private void updateEnabledState(Container c, boolean enabled) {
for (int counter = c.getComponentCount() - 1; counter >= 0;counter--) {
Component child = c.getComponent(counter);
--- 475,494 ----
}
/**
* Updates the enabled state of the children Components based on the
! * enabled state of the {@code JSpinner}.
*/
private void updateEnabledState() {
updateEnabledState(spinner, spinner.isEnabled());
}
/**
* Recursively updates the enabled state of the child
! * {@code Component}s of {@code c}.
*/
private void updateEnabledState(Container c, boolean enabled) {
for (int counter = c.getComponentCount() - 1; counter >= 0;counter--) {
Component child = c.getComponent(counter);
*** 533,543 ****
LazyActionMap.installLazyActionMap(spinner, BasicSpinnerUI.class,
"Spinner.actionMap");
}
/**
! * Returns the InputMap to install for <code>condition</code>.
*/
private InputMap getInputMap(int condition) {
if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
return (InputMap)DefaultLookup.get(spinner, this,
"Spinner.ancestorInputMap");
--- 533,543 ----
LazyActionMap.installLazyActionMap(spinner, BasicSpinnerUI.class,
"Spinner.actionMap");
}
/**
! * Returns the InputMap to install for {@code condition}.
*/
private InputMap getInputMap(int condition) {
if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
return (InputMap)DefaultLookup.get(spinner, this,
"Spinner.ancestorInputMap");
< prev index next >