views:

149

answers:

1

I am creating time picker using the spinner.In that the text inside the spinner is editable.But i want to set the spinner as non editable.Because is there chance to give invalid value.Can any one help me.?

+3  A: 

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.

jfpoilpret
I modified your code,It works Fine. JSpinner ampm=new JSpinner(); JFormattedTextField ampmspin=((JSpinner.DefaultEditor)ampm.getEditor()).getTextField(); ampmspin.setEditable(false);Thank you very much.........
Arivu2020