Search code examples
javajspinner

How to reset a JSpinner to min value


I need to reset a JSpinner to its min value. I've tried get it from model:

spinner.setValue(((SpinnerNumberModel) spinner.getModel()).getMinimum());

But i've got IllegalArgumentException...


Solution

  • That can happen if your model doesn't have a minimum, or if its minimum is a Comparable that is not a Number.