点关闭没反应,不知哪错了,帮忙看看那
import java.awt.*;
import java.awt.event.*;
class day2204
{
public static void main(String[] args)
{
//Frame事件源
Frame f = new Frame("my frame");//默认的布局 边界式
f.setSize(500,500);
f.setLocation(50,40);
f.setLayout(new FlowLayout());
Button b = new Button("我d按钮");
f.add(b);
//添加监听器 监听器里面放到是动作
f.addWindowListener(new mywindow());
f.setVisible(true);
//System.out.println("Hello World!");
}
}
class mywindow extends WindowAdapter
{
public void windowsClosing(WindowEvent e)
{
System.out.println("关闭"+e.toString());
System.exit(0);
}
} |