3月24日,TestFrame采用适配器形式产生匿名对象,每日20行。

import java.awt.*;
import java.awt.event.*;
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 WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.out.println("我退出了!");
                e.getWindow().setVisible(false);
                ((Window)e.getComponent()).dispose();
                System.exit(0);
            }
        });
    }

}

3月24日,TestFrame采用适配器形式产生匿名对象,每日20行。_第1张图片
这里写图片描述

你可能感兴趣的:(3月24日,TestFrame采用适配器形式产生匿名对象,每日20行。)