⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windowclosing.java

📁 《JAVA程序设计教程》源代码
💻 JAVA
字号:
//WindowClosing.java

import javax.swing.*;
import java.awt.event.*;

public class WindowClosing
{  
	public static void main(String[] args)
	{  
		SimpleFrame frame = new SimpleFrame();
		
		//设置用户关闭框架时的响应动作
		frame.addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				System.exit(0);
			}
		});
		
		//显示该框架
		frame.show();  
   }
}

class SimpleFrame extends JFrame
{
	public SimpleFrame()
	{
		//设置框架大小
		setSize(WIDTH, HEIGHT);
	}
	
	public static final int WIDTH = 300;
	public static final int HEIGHT = 200;  	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -