I have a few jspinners
, they are: min char
, max cha
r, min low char
, min up chars
etc. Now I need to set the max values of min low char
, min up char
, etc, to the max chars
, but jspinner
models dont allow any variables to set any model value. so how can what can I do to set the max values of those spinners to the value of max char
.
The SpinnerNumberModel has setMaximum and setMinimum methods. You could ask the spinner for it's model, and if it's an instanceof SpinnerNumberModel cast it.
Otherwise, you could maintain a reference to the original models used to populate the spinners in the first place and update them accordingly.
You can override getMaximum
with an anonymous model class to make it reference a member of the parent type. Eg
JSpinner minChar = new JSpinner(new SpinnerNumberModel() {
@Override
public Comparable<Integer> getMaximum() {
return maximum;
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.