Class JSpinner.NumberEditor

All Implemented Interfaces:
ImageObserver, LayoutManager, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, ChangeListener
Enclosing class:
JSpinner

public static class JSpinner.NumberEditor extends JSpinner.DefaultEditor
An editor for a JSpinner whose model is a SpinnerNumberModel. The value of the editor is displayed with a JFormattedTextField whose format is defined by a NumberFormatter instance whose minimum and maximum properties are mapped to the SpinnerNumberModel.
Since:
1.4
  • Constructor Details

    • NumberEditor

      public NumberEditor(JSpinner spinner)
      Construct a JSpinner editor that supports displaying and editing the value of a SpinnerNumberModel with a JFormattedTextField. This NumberEditor becomes both a ChangeListener on the spinner and a PropertyChangeListener on the new JFormattedTextField.
      Parameters:
      spinner - the spinner whose model this editor will monitor
      Throws:
      IllegalArgumentException - if the spinners model is not an instance of SpinnerNumberModel
      See Also:
    • NumberEditor

      public NumberEditor(JSpinner spinner, String decimalFormatPattern)
      Construct a JSpinner editor that supports displaying and editing the value of a SpinnerNumberModel with a JFormattedTextField. This NumberEditor becomes both a ChangeListener on the spinner and a PropertyChangeListener on the new JFormattedTextField.
      Parameters:
      spinner - the spinner whose model this editor will monitor
      decimalFormatPattern - the initial pattern for the DecimalFormat object that's used to display and parse the value of the text field.
      Throws:
      IllegalArgumentException - if the spinners model is not an instance of SpinnerNumberModel or if decimalFormatPattern is not a legal argument to DecimalFormat
      See Also:
  • Method Details

    • getFormat

      public DecimalFormat getFormat()
      Returns the java.text.DecimalFormat object the JFormattedTextField uses to parse and format numbers.
      Returns:
      the value of getTextField().getFormatter().getFormat().
      See Also:
    • getModel

      public SpinnerNumberModel getModel()
      Return our spinner ancestor's SpinnerNumberModel.
      Returns:
      getSpinner().getModel()
      See Also:
    • setComponentOrientation

      public void setComponentOrientation(ComponentOrientation o)
      Sets the language-sensitive orientation that is to be used to order the elements or text within this component. Language-sensitive LayoutManager and Component subclasses will use this property to determine how to lay out and draw components.

      At construction time, a component's orientation is set to ComponentOrientation.UNKNOWN, indicating that it has not been specified explicitly. The UNKNOWN orientation behaves the same as ComponentOrientation.LEFT_TO_RIGHT.

      To set the orientation of a single component, use this method. To set the orientation of an entire component hierarchy, use applyComponentOrientation.

      This method changes layout-related information, and therefore, invalidates the component hierarchy.

      Overrides:
      setComponentOrientation in class Component
      Parameters:
      o - the orientation to be set
      See Also: