JSpinner with default value

The JSpinners are like to jcombo boxes and jlists in that they user can select input from a predetermined set of values.

Program

cxczxczxc

 

 

 

Program Source

import javax.swing.JFrame;
import javax.swing.JSpinner;
import java.awt.FlowLayout;
import java.awt.Dimension;

class JSpinnerTest extends JFrame {
       
    JSpinnerTest()
    {
        setTitle("JSpinnerTest");
        setLayout(new FlowLayout());
        setJSpinner();
        setSize(700,200);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
   
    void setJSpinner()
    {
        JSpinner js = new JSpinner();
        js.setPreferredSize(new Dimension(100,20));
        add(js);
    }
}

public class Javaapp {
   
    public static void main(String[] args) {
       
        JSpinnerTest js = new JSpinnerTest();
    }
}

Leave a Comment