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

📄 windoweventdemo.java

📁 本java源程序包括了大量的学习程序(共27章)方便大家学习
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class WindowEventDemo extends JFrame
{
	public WindowEventDemo()
	{
		super("窗口事件");
		setSize(400, 400);
		
		//设置窗口背景颜色
		getContentPane().setBackground(Color.GREEN);
		addWindowListener(new EventHandler());
		setVisible(true);
	}
   
    public static void main(String[] args)
    {
	    WindowEventDemo application = new WindowEventDemo();
    }
   
    class EventHandler extends WindowAdapter
    {
	    public void windowActivated(WindowEvent event)
	    {
	      //windowActivated激活窗口事件处理
		    System.out.println("激活窗口");
	    }
	   
	    public void windowDeactivated(WindowEvent event)
	    {
	    	//windowDeactivated非激活窗口事件处理
		    System.out.println("窗口处于不活动状态");
	    }
	   
	    public void windowClosing(WindowEvent event)
	    {
	    	//windowClosing窗口关闭事件处理
		    System.out.println("关闭窗口");
	    }
	   
	    public void windowIconified(WindowEvent event)
	    {
	    	//windowIconified窗口最小化事件处理
		    System.out.println("窗口最小化");
	    }
	   
	    public void windowDeiconified(WindowEvent event)
	    {
	    	//windowDeiconified窗口还原事件处理
		    System.out.println("窗口还原");
	    } 
    }
}

⌨️ 快捷键说明

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