Search code examples
javaswingspinner

JSpinner get Max Min Value


I can get the current value by using getValue(), but is it possible to get the Maximum and Minimum allowable value for the JSpinner? Can't find method such as getMax() or getMin() for JSpinner from the docs.

http://docs.oracle.com/javase/7/docs/api/javax/swing/JSpinner.html

http://docs.oracle.com/javase/7/docs/api/javax/swing/SpinnerModel.html


Solution

  • Only some SpinnerModel's have the concept of min/max values.

    So you need to look at the specific model you are using for your spinner. For example,

    1. SpinnerNumberModel
    2. SpinnerDateModel