addWindowListener -> WindowAdapter -> windowClosing
2020-12-13 05:50
标签:style blog http color java os io for Suppose we have a frame To catch window closing events and quit, there are two ways (as I know): Way1. Explanation: Exit the system when the window is closed. Way2. Explanation (reference): This catching action is necessary. The system would not quit even if the window has been closed without this event. You can try it yourself. WindowAdapter -> windowClosing,soscw.com" href="http://www.soscw.com/infodetail-290148.html" target="_blank">addWindowListener -> WindowAdapter -> windowClosing,搜素材,soscw.com WindowAdapter -> windowClosing,soscw.com" target="_blank">addWindowListener -> WindowAdapter -> windowClosing 标签:style blog http color java os io for 原文地址:http://www.cnblogs.com/skyssky/p/3886547.htmlfinal JFrame jframe = new JFrame("Triangle 3");
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
jframe.dispose(); // to release resources for OpenGL
System.exit(0);
}
});
给窗口注册一个事件监听器,
当你点了窗口右上方的叉号时
此方法被调用
若对语法不懂,学习关于java inner class的知识
上一篇:数组简介
文章标题:addWindowListener -> WindowAdapter -> windowClosing
文章链接:http://soscw.com/essay/31845.html