本帖最后由 华行天下 于 2013-10-12 20:04 编辑
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class gui1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Frame f=new Frame("my awt");
f.setSize(500, 400);
f.setLocation(300, 200);
f.setLayout(new FlowLayout());
Button b=new Button("按钮");
f.add(b);
f.addWindowListener(new MyWin());
f.setVisible(true);
//System.out.println("guichengxian");
}
}
class MyWin extends WindowAdapter{
public void WindowClosing(WindowEvent e){
System.out.println("Closeing Window");
}
}
程序能运行没有错误,但是监听事件没有效果;想知道怎么回事? |