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

Print this page




  76  * <pre>
  77  *   try {
  78  *       spinner.commitEdit();
  79  *   }
  80  *   catch (ParseException pe) {{
  81  *       // Edited value is invalid, spinner.getValue() will return
  82  *       // the last valid value, you could revert the spinner to show that:
  83  *       JComponent editor = spinner.getEditor()
  84  *       if (editor instanceof DefaultEditor) {
  85  *           ((DefaultEditor)editor).getTextField().setValue(spinner.getValue();
  86  *       }
  87  *       // reset the value to some known value:
  88  *       spinner.setValue(fallbackValue);
  89  *       // or treat the last valid value as the current, in which
  90  *       // case you don't need to do anything.
  91  *   }
  92  *   return spinner.getValue();
  93  * </pre>
  94  * <p>
  95  * For information and examples of using spinner see
  96  * <a href="http://java.sun.com/doc/books/tutorial/uiswing/components/spinner.html">How to Use Spinners</a>,
  97  * a section in <em>The Java Tutorial.</em>
  98  * <p>
  99  * <strong>Warning:</strong> Swing is not thread safe. For more
 100  * information see <a
 101  * href="package-summary.html#threading">Swing's Threading
 102  * Policy</a>.
 103  * <p>
 104  * <strong>Warning:</strong>
 105  * Serialized objects of this class will not be compatible with
 106  * future Swing releases. The current serialization support is
 107  * appropriate for short term storage or RMI between applications running
 108  * the same version of Swing.  As of 1.4, support for long term storage
 109  * of all JavaBeans<sup><font size="-2">TM</font></sup>
 110  * has been added to the <code>java.beans</code> package.
 111  * Please see {@link java.beans.XMLEncoder}.
 112  *
 113  * @beaninfo
 114  *   attribute: isContainer false
 115  * description: A single line input field that lets the user select a
 116  *     number or an object value from an ordered set.




  76  * <pre>
  77  *   try {
  78  *       spinner.commitEdit();
  79  *   }
  80  *   catch (ParseException pe) {{
  81  *       // Edited value is invalid, spinner.getValue() will return
  82  *       // the last valid value, you could revert the spinner to show that:
  83  *       JComponent editor = spinner.getEditor()
  84  *       if (editor instanceof DefaultEditor) {
  85  *           ((DefaultEditor)editor).getTextField().setValue(spinner.getValue();
  86  *       }
  87  *       // reset the value to some known value:
  88  *       spinner.setValue(fallbackValue);
  89  *       // or treat the last valid value as the current, in which
  90  *       // case you don't need to do anything.
  91  *   }
  92  *   return spinner.getValue();
  93  * </pre>
  94  * <p>
  95  * For information and examples of using spinner see
  96  * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/spinner.html">How to Use Spinners</a>,
  97  * a section in <em>The Java Tutorial.</em>
  98  * <p>
  99  * <strong>Warning:</strong> Swing is not thread safe. For more
 100  * information see <a
 101  * href="package-summary.html#threading">Swing's Threading
 102  * Policy</a>.
 103  * <p>
 104  * <strong>Warning:</strong>
 105  * Serialized objects of this class will not be compatible with
 106  * future Swing releases. The current serialization support is
 107  * appropriate for short term storage or RMI between applications running
 108  * the same version of Swing.  As of 1.4, support for long term storage
 109  * of all JavaBeans<sup><font size="-2">TM</font></sup>
 110  * has been added to the <code>java.beans</code> package.
 111  * Please see {@link java.beans.XMLEncoder}.
 112  *
 113  * @beaninfo
 114  *   attribute: isContainer false
 115  * description: A single line input field that lets the user select a
 116  *     number or an object value from an ordered set.