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

📄 test.java

📁 java2图形设计卷1:awt 源码
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;

public class Test extends Frame {
	public Test() {
		super("WindowListener test");
	}
	public static void main(String args[]) {
		final Frame f = new Test();
		f.setBounds(100,100,250,150);
		f.setVisible(true);
		f.addWindowListener(new TestWindowListener());
	}
}
class TestWindowListener implements WindowListener {
	public void windowActivated(WindowEvent e) {
		System.out.println("window activated");
	}
	public void windowClosed(WindowEvent e) {
		System.out.println("window closed");
		System.exit(0);
	}
	public void windowClosing(WindowEvent e) {
		System.out.println("window closing ...");
		Window w = e.getWindow();
		w.dispose();
	}
	public void windowDeactivated(WindowEvent e) {
		System.out.println("window deactivated");
	}
	public void windowDeiconified(WindowEvent e) {
		System.out.println("window deiconified");
	}
	public void windowOpened(WindowEvent e) {
		System.out.println("window opened");
	}
}

⌨️ 快捷键说明

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