eventhandlingdemo2.java
来自「JAVA程序设计课程中各章节的程序实例。」· Java 代码 · 共 49 行
JAVA
49 行
/**
*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 + =
减小字号Ctrl + -
显示快捷键?