3月20日,TestFrame_Listener,每日20行。

来源:互联网 发布:php空间 免备案 编辑:程序博客网 时间:2024/04/29 02:56
import java.awt.*;import java.awt.event.*;class MyWindowListener implements WindowListener {    public void windowClosing(WindowEvent e) {        System.out.println("我退出了!");        e.getWindow().setVisible(false);    //变为不显示        ((Window)e.getComponent()).dispose();    //释放窗口资源        System.exit(0);    //退出系统    }    public void windowActivated(WindowEvent e) {}    public void windowClosed(WindowEvent e) {}    public void windowDeactivated(WindowEvent e) {}    public void windowDeiconified(WindowEvent e) {}    public void windowIconified(WindowEvent e) {}    public void windowOpened(WindowEvent e) {}};public class TestFrame {    public static void main(String[] args) {        Frame f = new Frame("A Test Window");        f.setSize(320, 180);        f.setVisible(true);        f.addWindowListener(new MyWindowListener());    }}

这里写图片描述
这里写图片描述

0 0
原创粉丝点击