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.
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( ... );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.