I\'m making an application that uses a JSpinner with a max number 30,I should choose a value from this JSpinner and tape a String to the JTextField and the result will appear in
For one, it appears you have an infinite loop in your code. Inside your jSpinner1StateChanged function, you are calling jSpinner1StateChanged(evt)
, which will cause an infinite loop.
How are you creating your JSpinner? If you're using ints, then create it by using a SpinnerNumberModel
. This will simplify your code when getting the current value out of the spinner.
jSpinner1 = new JSpinner(new SpinnerNumberModel(0, 0, 30, 1));
Integer currentValue = (Integer)jSpinner1.getValue();