< prev index next >

src/java.desktop/share/classes/javax/swing/JSpinner.java

Print this page




 752                     // Try to set the new value
 753                     try {
 754                         spinner.setValue(getTextField().getValue());
 755                     } catch (IllegalArgumentException iae) {
 756                         // SpinnerModel didn't like new value, reset
 757                         try {
 758                             ((JFormattedTextField)source).setValue(lastValue);
 759                         } catch (IllegalArgumentException iae2) {
 760                             // Still bogus, nothing else we can do, the
 761                             // SpinnerModel and JFormattedTextField are now out
 762                             // of sync.
 763                         }
 764                     }
 765                 } else if ("font".equals(name)) {
 766                     Object newfont = e.getNewValue();
 767                     if (newfont instanceof UIResource) {
 768                         // The text field font must match the JSpinner font if
 769                         // the text field font was not set by the user
 770                         Font font = spinner.getFont();
 771                         if (!newfont.equals(font)) {
 772                             getTextField().setFont(new FontUIResource(font));
 773                         }
 774                     }
 775                 }
 776             }
 777         }
 778 
 779 
 780         /**
 781          * This <code>LayoutManager</code> method does nothing.  We're
 782          * only managing a single child and there's no support
 783          * for layout constraints.
 784          *
 785          * @param name ignored
 786          * @param child ignored
 787          */
 788         public void addLayoutComponent(String name, Component child) {
 789         }
 790 
 791 
 792         /**




 752                     // Try to set the new value
 753                     try {
 754                         spinner.setValue(getTextField().getValue());
 755                     } catch (IllegalArgumentException iae) {
 756                         // SpinnerModel didn't like new value, reset
 757                         try {
 758                             ((JFormattedTextField)source).setValue(lastValue);
 759                         } catch (IllegalArgumentException iae2) {
 760                             // Still bogus, nothing else we can do, the
 761                             // SpinnerModel and JFormattedTextField are now out
 762                             // of sync.
 763                         }
 764                     }
 765                 } else if ("font".equals(name)) {
 766                     Object newfont = e.getNewValue();
 767                     if (newfont instanceof UIResource) {
 768                         // The text field font must match the JSpinner font if
 769                         // the text field font was not set by the user
 770                         Font font = spinner.getFont();
 771                         if (!newfont.equals(font)) {
 772                             getTextField().setFont(font == null ? null : new FontUIResource(font));
 773                         }
 774                     }
 775                 }
 776             }
 777         }
 778 
 779 
 780         /**
 781          * This <code>LayoutManager</code> method does nothing.  We're
 782          * only managing a single child and there's no support
 783          * for layout constraints.
 784          *
 785          * @param name ignored
 786          * @param child ignored
 787          */
 788         public void addLayoutComponent(String name, Component child) {
 789         }
 790 
 791 
 792         /**


< prev index next >