How to capture closing event in java swing

I want to capture the window close event (red X on the right). I want to display the specified window in this window based on the event.

+3
source share
2 answers

Register WindowListener - in particular, use windowClosing :

Called when a user tries to close a window from a system menu window.

+3
source

You need to either implement the WindowListener interface or register a WindowAdapter .

+2
source

All Articles