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.<
I have found a very simple way to solve this.
The JComboBox default editor has an internal class BasicComboBoxEditor$BorderlessTextField that is the component that gets and loses focus.
It can be accessed simply by
Component component = comboBox.getEditor().getEditorComponent();
if (component instanceof JTextField)
JTextField borderlesstextfield = (JTextField) borderless;
Then add a focus listener like you would to any JTextField
borderlesstextfield.addFocusListener(new FocusListener()
{
public void focusGained(FocusEvent e)
{
}
public void focusLost(FocusEvent e)
{
}
}});
Now you have a FocusListener that will respond as expected to gain and loss of focus for the ComboBox