I have a jSpinner with a SpinnerNumberModel like this:
spinnerModelFix = new SpinnerNumberModel(0, 0, 65535, 1);
JSpinner fixedValueSpinner = new JSpinner(spinnerModelFix);
I just want to show Integers in the spinner, so that if the user insert letters they aren’t shown.
I thought I should extends SpinnerNumberModel and override the fireStateChanged() method…
But I’m not sure what I need to do in that method.
Can anyone give me some hint?
yes is possible and workaround is quite simple,
there are two ways how to do it, have to derive
JTextFieldorJFormattedTextFieldfromJSpinner,then to add
a)
DocumentListenerb)
DocumentFilterI think that usage of DocumentFilter is easiest for code workaround, better, maybe safer