To see a JSpinner in action, look at the Font Shower Amanuesis that uses one to let you
control the font size. You can use the arrow keys to change the value, or you can
type in a new value. Here is the basic code to make one work.
You can customise how the spinner values jump by writing your own SpinnerModel. You can customise how the display looks and how you
can edit it by writing a custom JComponent and using
JSpinner. setEditor. If you
want to roll your own, it is wise to look at Oracle’s implementations to
understand just what these classes do. The source is in J:\Program Files\java\jdk1.8.0_131\
\src.zip. Here is a crude example of how you would spin a formatted value.
For a more real-world example see the source code for the Canadian Tax Calculator.
A JSpinner is actually three little JComponents, a JFormattedTextField and
up arrow button and a down arrow button. When methods don’t behave as you
would expect when called on the JSpinner as a whole, try
using JSpinner.NumberEditor.getTextField and doing your operations on that subcomponent, e.g.
tabbing, event notification etc.