user1137559
user1137559

Reputation: 31

How to capture a close event in java swing

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.

Upvotes: 3

Views: 5502

Answers (2)

mre
mre

Reputation: 44240

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

Upvotes: 3

ziesemer
ziesemer

Reputation: 28687

Register a WindowListener - specifically, use its windowClosing method:

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

Upvotes: 3

Related Questions