How can I check when a JFrame has been closed?

若如初见. 提交于 2019-12-31 04:22:14

问题


How do I check when JFrame window is closed?

MediaPanel mediaPanel=new MediaPanel();
JFrame_of_subtitle frame=new JFrame_of_subtitle(mediaPanel);
JPanel panel=new JPanel();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

回答1:


You will add WindowListener to your frame.

WindowListener has a windowClosing callback function which will be invoked when your frame is being closed.

You can see this tutorial for sample code.



来源:https://stackoverflow.com/questions/10370064/how-can-i-check-when-a-jframe-has-been-closed

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