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

📄 eventhandlingdemo2.java

📁 JAVA程序设计课程中各章节的程序实例。
💻 JAVA
字号:
/**
*A event handling program shows the precise way of closing a frame window!
*By implementing the WindowListener interface
*2004.12.28. xhcprince
*/

import java.awt.*;
import java.awt.event.*;

public class EventHandlingDemo2 extends Frame implements WindowListener
{
	public EventHandlingDemo2()
	{
		addWindowListener(this);	//this is listener registration
		
		setSize(300,300);
		setVisible(true);
	}
/*------------------------------------------------------------------------
	Implementing all the WindowListener methods,you have to override these
	methods!Because WindowListener is an interface,all the methods should 
	be implemented in the subclass(here is EventhandlingDemo2)!
	Pay more attention of it!
------------------------------------------------------------------------*/
									
	public void windowClosed(WindowEvent e){}
	
	public void windowIconified(WindowEvent e){}
	
	public void windowOpened(WindowEvent e){}
	
	public void windowDeiconified(WindowEvent e){}
	
	public void windowActivated(WindowEvent e){}
	
	public void windowDeactivated(WindowEvent e){}
	
	public void windowClosing(WindowEvent e)
	{
		System.exit(0);
	}

	public static void main(String args[])
	{
		EventHandlingDemo2 obj = new EventHandlingDemo2();
	}
}

⌨️ 快捷键说明

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