📄 9.12-testwindowevent.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 + -