How to capture a close event in java swing
Asked Answered
F

2

3

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.

Flipper answered 8/1, 2012 at 20:40 Comment(0)
A
3

Register a WindowListener - specifically, use its windowClosing method:

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

Allegra answered 8/1, 2012 at 20:42 Comment(0)
A
3

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

Aldoaldol answered 8/1, 2012 at 20:42 Comment(1)
Just to add, this tutorial covers an example of implementing a WindowsListener for Close operation docs.oracle.com/javase/tutorial/uiswing/events/…Parttime

© 2022 - 2024 — McMap. All rights reserved.