JSpinner get Max Min Value

2019-09-09 12:47发布

问题:

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

回答1:

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