Java JSpinner create for double type

Description

Java JSpinner create for double type

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());

      Double current = new Double(5.50);
      Double min = new Double(0.00);
      Double max = new Double(10.00);
      Double step = new Double(0.25);
      SpinnerNumberModel m_numberSpinnerModel = new SpinnerNumberModel(current, min, max, step);
      JSpinner spinner = new JSpinner(m_numberSpinnerModel);
      /*from ww  w. j  a v a 2 s. c  o m*/
      getContentPane().add(spinner);
   }

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



PreviousNext

Related