Java – jwindow never gets focus events
•
Java
I have a jwindow (set to always be at the top) that you can click to get a pop-up menu If the user right clicks a window, a pop-up menu is displayed, but if the user clicks any other window, such as Firefox, the pop-up menu does not disappear
I tried to fix it by adding focuslistener on jwindow. I implemented focuslistener and overridden it
public void focusGained(FocusEvent e) {
System.out.println("gain" );
}
public void focusLost(FocusEvent e) {
System.out.println("lost" );
}
But events will never be called I've also tried the following,
addWindowFocusListener(new WindowAdapter() {
public void windowGainedFocus(WindowEvent e) {
System.out.println("gain 2" );
}
});
This event is not called
All these jwindows have a jlabel with a picture on it
Solution
Jwindow did not receive focus / window event from memory
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
