spinner.getValue()
should do the trick. You can cast it to Integer
, like
int value = (Integer) spinner.getValue();
Note from reggoodwin: You should also call spinner.commitEdit()
prior to calling getValue()
to ensure manually typed values with the editor are propagated to the model, otherwise you will only get the old value.
Hence, it should be something like below,
try {
spinner.commitEdit();
} catch ( java.text.ParseException e ) { .. }
int value = (Integer) spinner.getValue();