I have a JCombobox in my code. I have added the FocusLost event. But it didn’t fired anyway. I have tried lots of time but didn’t find solution.
jcbItemType.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
jcbItemTypeFocusLost(evt);
}
});
private void jcbItemTypeFocusLost(java.awt.event.FocusEvent evt)
{
// TODO add your handling code here:
System.out.println("name=" + ((Component) evt.getSource()).getName());
System.out.println("index=" + jcbItemType.getSelectedIndex());
}
But nothing is printed in console. Please suggest me what I am doing wrong.
FocusListener isn’t proper Listener for JComboBox, altogether with another Listener(s) can creating endless loop (especially Editable JComboBox),
FocusListener is asynchronous, sometimes is too hard to catch events is right orders especially in the cases that JComponents has added another Listener(s) too
example how to listening for Focus from derived
JTextField / JFormattedTextField