/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JSpinner}.
*
* @author Hans Muller
* @author Joshua Outwater
* @since 1.7
*/
implements PropertyChangeListener, SynthUI {
/**
* A FocusListener implementation which causes the entire spinner to be
* repainted whenever the editor component (typically a text field) becomes
* focused, or loses focus. This is necessary because since SynthSpinnerUI
* is composed of an editor and two buttons, it is necessary that all three
* components indicate that they are "focused" so that they can be drawn
* appropriately. The repaint is used to ensure that the buttons are drawn
* in the new focused or unfocused state, mirroring that of the editor.
*/
/**
* Returns a new instance of SynthSpinnerUI.
*
* @param c the JSpinner (not used)
* @see ComponentUI#createUI
* @return a new SynthSpinnerUI object
*/
return new SynthSpinnerUI();
}
/**
* @inheritDoc
*/
protected void installListeners() {
super.installListeners();
spinner.addPropertyChangeListener(this);
}
}
}
/**
* @inheritDoc
*/
protected void uninstallListeners() {
super.uninstallListeners();
}
}
}
/**
* Initializes 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
* @see LookAndFeel#installColors
*/
protected void installDefaults() {
}
}
// Only call installKeyboardActions as uninstall is not
// public.
}
}
}
/**
* 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() {
}
}
/**
* @inheritDoc
*/
return new SpinnerLayout();
}
/**
* @inheritDoc
*/
b.setName("Spinner.previousButton");
return b;
}
/**
* @inheritDoc
*/
b.setName("Spinner.nextButton");
return b;
}
/**
* 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
*/
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.
*
* @see #createEditor
* @see #createPropertyChangeListener
*/
}
}
}
}
}
context, "Spinner.editorAlignment");
}
// copy across the sizeVariant property to the editor
}
}
/**
* @inheritDoc
*/
}
}
/**
* Notifies this UI delegate to repaint the specified component.
* This method paints the component background, then calls
* the {@link #paint(SynthContext,Graphics)} method.
*
* <p>In general, this method does not need to be overridden by subclasses.
* All Look and Feel rendering code should reside in the {@code paint} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
}
/**
* Paints the specified component according to the Look and Feel.
* <p>This method is not used by Synth Look and Feel.
* Painting is handled by the {@link #paint(SynthContext,Graphics)} method.
*
* @param g the {@code Graphics} object used for painting
* @param c the component being painted
* @see #paint(SynthContext,Graphics)
*/
}
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
}
/**
* @inheritDoc
*/
int y, int w, int h) {
}
/**
* See the SynthSpinnerUI javadoc for more information about exactly
* how the components are arranged.
*/
{
nextButton = c;
}
previousButton = c;
}
editor = c;
}
}
if (c == nextButton) {
nextButton = null;
}
else if (c == previousButton) {
}
else if (c == editor) {
}
}
}
/* Force the editors height to be a multiple of 2
*/
return size;
}
return preferredLayoutSize(parent);
}
if (c != null) {
}
}
/* Deal with the spinners componentOrientation property.
*/
}
else {
}
}
}
/**
* @inheritDoc
*/
if (spinnerUI instanceof SynthSpinnerUI) {
if (SynthLookAndFeel.shouldUpdateStyle(e)) {
}
}
}
/** Listen to editor text field focus changes and repaint whole spinner */
/** Invoked when a editor text field gains the keyboard focus. */
}
/** Invoked when a editor text field loses the keyboard focus. */
}
}
}