In my program, I wanted to invoke an ActionEvent
on a TextField
named descField
, when the focus is lost. I used dispatchEvent
successfully. When I changed the TextField
to a JTextField
, it doesn't work. I would be grateful for some help (I am an amateur with Java). Here is the dispatcher which is the focusLost
method of my JTextField
:
public void focusLost(FocusEvent f) {
ActionEvent action = new ActionEvent(descField, ActionEvent.ACTION_PERFORMED, "focus_lost");
descField.dispatchEvent(action); // Causes actionPerformed to be invoked
// Does not work with JTextArea
} //focusLost
How can I make it work using JTextField
, instead of TextField
?