Java JSpinner set value

Description

Java JSpinner set value

import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JSpinner;

public class Main extends JFrame {
   public Main() {
      super("java2s.com");

      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setLayout(new FlowLayout());

      // Create a number spinner
      JSpinner spinner = new JSpinner();

      // Set its value
      spinner.setValue(new Integer(100));
      //from ww  w  .j  ava 2s.co  m
      getContentPane().add(spinner);
   }

   public static void main(String[] args) {
      Main frame = new Main();
      frame.pack();
      frame.setVisible(true);
   }
}



PreviousNext

Related