We can set up JSpinner with an editor object to display the current value.
JSpinner has the following three static inner classes to display three different kinds of ordered lists:
import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; public class Main extends JFrame { public Main() { super("java2s.com"); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new FlowLayout()); int minValue = 1; int maxValue = 10; int currentValue = 5; int steps = 1; SpinnerNumberModel nModel = new SpinnerNumberModel(currentValue, minValue, maxValue, steps); JSpinner spinner = new JSpinner(nModel); JSpinner.NumberEditor nEditor = new JSpinner.NumberEditor(spinner, "00"); spinner.setEditor(nEditor);// w w w. j av a 2s . co m getContentPane().add(spinner); } public static void main(String[] args) { Main frame = new Main(); frame.pack(); frame.setVisible(true); } }