I have a JSpinner
with ChangeListener
directed. But the ChangeListener
is only activated when I press enter or click on one of the JSpinner
buttons. I would like to know how to enable ChangeListener
when the value is changed.
Asked
Active
Viewed 3,081 times
0

Andrew Thompson
- 168,117
- 40
- 217
- 433

Leonardo Paixão
- 1
- 1
- 1
-
Technically, that is what happening. Do you mean you want to know when the user toes something? – MadProgrammer Jun 17 '13 at 20:19
-
Yes.. I want to know when the user change the default value of the Jspinner – Leonardo Paixão Jun 17 '13 at 20:30
1 Answers
3
You need to add a listener to the editor to be notified of any change:
JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor)spinner.getEditor();
JTextField textField = editor.getTextField();
textField.getDocument().addDocumentListener( ... );

camickr
- 321,443
- 19
- 166
- 288