I set the valid range from 0 to 10
JSpinner spin = new JSpinner();
spin.setModel(new SpinnerNumberModel(8.0, 0.0, 10.0, 0.5);
if the user input an invalid value, for example 12.0 and press TAB key, the JSpinner will automatically reset the value back to 8.0.
In my JFC Unit test, I attempted to invoke the TAB key strike event, but the JSpinner did not reset the value.
getHelper().sendKeyAction(new KeyEventData(this, spin, KeyEvent.VK_TAB));
assertEquals(8.0, spin.getValue());
I also tried to set the focus to another component, so that the JSpinner lost its forcus. It didn't work.
pauseAWT( );
another.requestFocus();
flushAWT( );
Do you know which event should I invoke? and how?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I set the valid range from 0 to 10
JSpinner spin = new JSpinner();
spin.setModel(new SpinnerNumberModel(8.0, 0.0, 10.0, 0.5);
if the user input an invalid value, for example 12.0 and press TAB key, the JSpinner will automatically reset the value back to 8.0.
In my JFC Unit test, I attempted to invoke the TAB key strike event, but the JSpinner did not reset the value.
getHelper().sendKeyAction(new KeyEventData(this, spin, KeyEvent.VK_TAB));
assertEquals(8.0, spin.getValue());
I also tried to set the focus to another component, so that the JSpinner lost its forcus. It didn't work.
pauseAWT( );
another.requestFocus();
flushAWT( );
Do you know which event should I invoke? and how?
Thanks