javaswingjspinner

List of numbers component on Swing


I want to show the same as the input type number of HTML5 but on Swing. This image illustrate what I want to do:

and the number is going from 0 to 999 for example

and the number is going from 0 to 999 for example

How can I make the same using Java Swing?


Solution

  •     public class MyFrame(){
    
            SpinnerModel spinnerModel = new SpinnerNumberModel(0,0,999,1);
            JSpinner anlist = new JSpinner(spinnerModel);
            JPanel panel1 = new JPanel();
    
            public MyFrame(){
    
                     panel1.add(anlist);
    
                            }
    
    }