I have got a JTextField
and I want to add listener to it, which will receive some event as soon as the JTextField
looses focus (say when I press with mouse to another component). Also I want a listener to receive an event when the text
parameter of JTextField
is changed (like when I set jtextfield.setText(anotherText)
). Any idea how should I do it?
For the first one, you need a FocusListener. For the second one, you need to add a DocumentListener to the document of the text field.