windowclosing.java
来自「一个GUI编程的例子 一个GUI编程的例子」· Java 代码 · 共 25 行
JAVA
25 行
import javax.swing.*;
import java.awt.event.*;
public class WindowClosing{
public static void main(String[] args) {
JFrame frame = new JFrame();
//设置用户关闭框架时的响应动作
frame.addWindowListener(new QuitWindow());
frame.setSize(200,300);
frame.show(); //显示该框架
}
}
class QuitWindow implements WindowListener
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
public void windowOpened(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?