JWindow never receives focus events
I have a jwindow (set always on top) that you can click to get a pop menu. If the user right-clicks on the window, the popup menu will appear, but if the user clicks on any other window (like firefox), the pop pop menu will not disappear.
I tried to fix it by adding FocusListener to jwindow, I implemented FocusListener and override
public void focusGained(FocusEvent e) {
System.out.println("gain" );
}
public void focusLost(FocusEvent e) {
System.out.println("lost" );
}
but events are never called. I have also tried the following,
addWindowFocusListener(new WindowAdapter() {
public void windowGainedFocus(WindowEvent e) {
System.out.println("gain 2" );
}
});
this event is not fired either.
All these jwindows have one JLabel with an image on it.
+2
source to share
5 answers