I'm adding the following code to a JTextField
FocusListener listener = new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// do nothing
}
@Override
public void focusLost(FocusEvent e) {
valueChanged();
}
};
field.addFocusListener( listener);
It works great when I click around from one field to another, but when I click on a save button, the event is not called. This is a plugin to a project, so I do not have access add a listener to the button itself.
But shouldn't clicking on the button call the focusLost event?
I quickly hacked together what I thought would be a temporary solution by injecting code, but no dice.
JTextField textField = new JTextField();
textField.setVisible(true);
textField.setFocusable(true);
textField.requestFocusInWindow();
textField.grabFocus();