How to capture a close event in java swing

5.5k Views Asked by At

I want to capture window close(red X right top position) event. I want to display a specified window upon that window based on the event.

2

There are 2 best solutions below

0
On

Register a WindowListener - specifically, use its windowClosing method:

Invoked when the user attempts to close the window from the window's system menu.

1
On

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