How to capture a close event in java swing

狂风中的少年 提交于 2019-12-23 21:03:43

问题


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.


回答1:


Register a WindowListener - specifically, use its windowClosing method:

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




回答2:


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



来源:https://stackoverflow.com/questions/8781108/how-to-capture-a-close-event-in-java-swing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!