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.
Register WindowListener - in particular, use windowClosing :
WindowListener
windowClosing
Called when a user tries to close a window from a system menu window.
You need to either implement the WindowListener interface or register a WindowAdapter .
WindowAdapter