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

📄 9.12-testwindowevent.java

📁 介绍有关java的资料 课件 相当一本书籍 里面都是很基础的知识
💻 JAVA
字号:
// TestWindowEvent.java: Create a frame to test window events
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;

public class TestWindowEvent extends JFrame
  implements WindowListener
{
  // Main method
  public static void main(String[] args)
  {
    TestWindowEvent frame = new TestWindowEvent();
    // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("Test Window Event");
    frame.setSize(100, 80);
    frame.setVisible(true);
  }

  // Default constructor
  public TestWindowEvent()
  {
    super();
    addWindowListener(this);  // Register listener
  }

 
  public void windowDeiconified(WindowEvent event)
  {
    System.out.println("Window deiconified");
  }

 
  public void windowIconified(WindowEvent event)
  {
    System.out.println("Window iconified");
  }

  
  public void windowActivated(WindowEvent event)
  {
    System.out.println("Window activated");
  }

 
  public void windowDeactivated(WindowEvent event)
  {
    System.out.println("Window deactivated");
  }

  
  public void windowOpened(WindowEvent event)
  {
    System.out.println("Window opened");
  }

 
  public void windowClosing(WindowEvent event)
  {
    System.out.println("Window closing");
  }

 
  public void windowClosed(WindowEvent event)
  {
    System.out.println("Window closed");
  }
}

⌨️ 快捷键说明

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