The valid range for this application is 0 to 9 but there seems to be no NetBeans 7.0.1 JSpinner minimum or maximum value setting. Is there another way to limit the range of this JSpinner to 0..9?
In my Netbeans 7.3 i followed theese steps:
Step 1:
Step 2:
Step 3:
And final step 4:
That works for me.
// from 0 to 9, in 1.0 steps start value 5
SpinnerNumberModel model1 = new SpinnerNumberModel(5.0, 0.0, 9.0, 1.0);
JSpinner spin1 = new JSpinner(model1);
You'll have to use this constructor of SpinnerNumberModel
.
Snippet:
JFrame frame = new JFrame("Limiting value for a JSpinner");
SpinnerModel sm = new SpinnerNumberModel(0, 0, 9, 1); //default value,lower bound,upper bound,increment by
JSpinner spinner = new JSpinner(sm);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With