Java Swing How to - Create a number JSpinner








Question

We would like to know how to create a number JSpinner.

Answer

//from w  w w.j  a  va 2s. c  o m

import javax.swing.JSpinner;

public class Main {
  public static void main(String[] argv) throws Exception {
    // Create a number spinner
    JSpinner spinner = new JSpinner();

    // Set its value
    spinner.setValue(new Integer(100));
  }
}