public static class

JSpinner.NumberEditor

extends JSpinner.DefaultEditor
java.lang.Object
   ↳ java.awt.Component
     ↳ java.awt.Container
       ↳ javax.swing.JComponent
         ↳ javax.swing.JPanel
           ↳ javax.swing.JSpinner.DefaultEditor
             ↳ javax.swing.JSpinner.NumberEditor

Class Overview

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.

Summary

[Expand]
Inherited Constants
From class javax.swing.JComponent
From class java.awt.Component
From interface java.awt.image.ImageObserver
[Expand]
Inherited Fields
From class javax.swing.JComponent
Public Constructors
JSpinner.NumberEditor(JSpinner spinner)
Construct a JSpinner editor that supports displaying and editing the value of a SpinnerNumberModel with a JFormattedTextField.
JSpinner.NumberEditor(JSpinner spinner, String decimalFormatPattern)
Construct a JSpinner editor that supports displaying and editing the value of a SpinnerNumberModel with a JFormattedTextField.
Public Methods
DecimalFormat getFormat()
Returns the java.text.DecimalFormat object the JFormattedTextField uses to parse and format numbers.
SpinnerNumberModel getModel()
Return our spinner ancestor's SpinnerNumberModel.
[Expand]
Inherited Methods
From class javax.swing.JSpinner.DefaultEditor
From class javax.swing.JPanel
From class javax.swing.JComponent
From class java.awt.Container
From class java.awt.Component
From class java.lang.Object
From interface java.awt.LayoutManager
From interface java.awt.MenuContainer
From interface java.awt.image.ImageObserver
From interface java.beans.PropertyChangeListener
From interface javax.accessibility.Accessible
From interface javax.swing.event.ChangeListener

Public Constructors

public JSpinner.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

public JSpinner.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

Public Methods

public DecimalFormat getFormat ()

Returns the java.text.DecimalFormat object the JFormattedTextField uses to parse and format numbers.

Returns
  • the value of getTextField().getFormatter().getFormat().

public SpinnerNumberModel getModel ()

Return our spinner ancestor's SpinnerNumberModel.

Returns
  • getSpinner().getModel()