1 /*
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
715 if ("editor".equals(propertyName)) {
716 final JComponent oldEditor = (JComponent) e.getOldValue();
717 final JComponent newEditor = (JComponent) e.getNewValue();
718 ui.replaceEditor(oldEditor, newEditor);
719 ui.updateEnabledState();
720 } else if ("componentOrientation".equals(propertyName)) {
721 ComponentOrientation o
722 = (ComponentOrientation) e.getNewValue();
723 if (o != e.getOldValue()) {
724 JComponent editor = spinner.getEditor();
725 if (editor != null) {
726 editor.applyComponentOrientation(o);
727 }
728 spinner.revalidate();
729 spinner.repaint();
730 }
731 } else if ("enabled".equals(propertyName)) {
732 ui.updateEnabledState();
733 } else if (JComponent.TOOL_TIP_TEXT_KEY.equals(propertyName)) {
734 ui.updateToolTipTextForChildren(spinner);
735 } else if ("font".equals(propertyName)) {
736 JComponent editor = spinner.getEditor();
737 if (editor instanceof JSpinner.DefaultEditor) {
738 JTextField tf
739 = ((JSpinner.DefaultEditor) editor).getTextField();
740 if (tf != null) {
741 if (tf.getFont() instanceof UIResource) {
742 tf.setFont(new FontUIResource(spinner.getFont()));
743 }
744 }
745 }
746 }
747 }
748 }
749 }
750
751 // Syncronizes the ToolTip text for the components within the spinner
752 // to be the same value as the spinner ToolTip text.
753 void updateToolTipTextForChildren(final JComponent spinnerComponent) {
754 final String toolTipText = spinnerComponent.getToolTipText();
755 final Component[] children = spinnerComponent.getComponents();
|
1 /*
2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
715 if ("editor".equals(propertyName)) {
716 final JComponent oldEditor = (JComponent) e.getOldValue();
717 final JComponent newEditor = (JComponent) e.getNewValue();
718 ui.replaceEditor(oldEditor, newEditor);
719 ui.updateEnabledState();
720 } else if ("componentOrientation".equals(propertyName)) {
721 ComponentOrientation o
722 = (ComponentOrientation) e.getNewValue();
723 if (o != e.getOldValue()) {
724 JComponent editor = spinner.getEditor();
725 if (editor != null) {
726 editor.applyComponentOrientation(o);
727 }
728 spinner.revalidate();
729 spinner.repaint();
730 }
731 } else if ("enabled".equals(propertyName)) {
732 ui.updateEnabledState();
733 } else if (JComponent.TOOL_TIP_TEXT_KEY.equals(propertyName)) {
734 ui.updateToolTipTextForChildren(spinner);
735 } else if ("font".equals(propertyName) ||
736 "graphicsConfiguration".equals(propertyName)) {
737 JComponent editor = spinner.getEditor();
738 if (editor instanceof JSpinner.DefaultEditor) {
739 JTextField tf
740 = ((JSpinner.DefaultEditor) editor).getTextField();
741 if (tf != null) {
742 if (tf.getFont() instanceof UIResource) {
743 tf.setFont(new FontUIResource(spinner.getFont()));
744 }
745 }
746 }
747 }
748 }
749 }
750 }
751
752 // Syncronizes the ToolTip text for the components within the spinner
753 // to be the same value as the spinner ToolTip text.
754 void updateToolTipTextForChildren(final JComponent spinnerComponent) {
755 final String toolTipText = spinnerComponent.getToolTipText();
756 final Component[] children = spinnerComponent.getComponents();
|