本帖最后由 Sword 于 2013-5-9 22:23 编辑
package day22;
import java.awt.*;
import java.awt.Event.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class FrameDemo {
private Frame f;
private Button but;
FrameDemo(){
init();
}
public void init()
{
f=new Frame("my frame");
f.setSize(500,300);
f.setLocation(500,400);
f.setLayout(new FlowLayout());
but=new Button("my button");
f.add(but);
myEvent();
f.setVisible(true);
}
private void myEvent()
{
f.addWindowListener(new WindowAdapter(){
public void WindowClosing(WindowEvent e){
System.exit(0);
}
});
}
public static void main(String[] args) {
new FrameDemo();
}
}
为什么 System.exit(0);这句没有执行呢?就是点击窗口中的红叉没有成功关闭窗口 |
|