大家帮帮我啊,窗口无法关闭
import java.awt.*;import java.awt.event.*;
class TestFrame{
public static void main(String[] args){
Frame f=new Frame("IT人资迅交流网");
//f.add(new Button("oK"));
f.add(new Button("确定"));
f.setSize(300,300);
f.setVisible(true);
}
}
//为窗口添加关闭功能
class MyWindowListener implements WindowListener{
public void windowClosing(WindowEvent e){
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){}
}
我用的是JCreator Pro,这是书上例子,但是无法关闭窗口,请大虾们修改一下,并简要说明一下原因,谢谢