how can I get the value of a the selected item in a JSpinner?

前端 未结 1 1927
感动是毒
感动是毒 2021-02-10 05:02

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

相关标签:
1条回答
  • 2021-02-10 05:17

    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();
    
    0 讨论(0)
提交回复
热议问题