How to undo changes on JSpinner?

I need to check the user input JSpinner

, and if it is wrong, I need to undo (rollback) the value change. What's the best way to do this?

0


source to share


1 answer


Well, if you keep the old value since the last validation of the input, you can then reset the counter value back to the last valid value.

boolean valid = validate(spinner);
if (valid)
    validValue = spinner.getValue();
else
    spinner.setValue(validValue);

      



Maybe something like that.

+1


source







All Articles