Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set JSpinner as non editable?

I am creating time picker using a JSpinner. The text inside the JSpinner is editable. But I want to set the JSpinner as non editable, because there is the chance to give an invalid value. Can anyone help me?

like image 875
Arivu2020 Avatar asked May 25 '10 04:05

Arivu2020


1 Answers

Try the following:

JSpinner spinner = ...;
((DefaultEditor) spinner.getEditor()).getTextField().setEditable(false);

This should work as long as you didn't change the spinner editor yourself by calling spinner.setEditor(...).

Tell us if this helps.

like image 159
jfpoilpret Avatar answered Sep 27 '22 17:09

jfpoilpret