Reputation: 30022
Similar to how I could listen to key presses globally using KeyboardFocusManager
is there a way to listen globally for any opened (setVisible
call) JFrame
or Window
in Swing?
I could poll Window.getWindows()
to do this, but I was wondering if I could do this in an event-driven way.
Upvotes: 3
Views: 152
Reputation: 2245
Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent event) {
System.out.println(event);
}
}, AWTEvent.WINDOW_EVENT_MASK);
Upvotes: 5