How can I check when a JFrame has been closed?(如何检查 JFrame 何时关闭?)
问题描述
如何检查JFrame
窗口何时关闭?
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);
推荐答案
您将添加 WindowListener 到你的框架.
You will add WindowListener to your frame.
WindowListener 有一个 windowClosing 回调函数,将在您的框架关闭时调用.
WindowListener has a windowClosing callback function which will be invoked when your frame is being closed.
您可以查看此教程以获取示例代码.
You can see this tutorial for sample code.
这篇关于如何检查 JFrame 何时关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!