import java.awt.*;
import java.awt.event.*;
public class TestFrame extends Frame
{
TestFrame()
{
super("Windows");
setSize(350,200);
setVisible(true);
addWindowListener(new Win());
}
public static void main(String args[])
{
new TestFrame();
}
}
class Win extends WindowAdapter
{
public void windowsClosing(WindowEvent e)
{
System.exit(0);
}
}
运行之后跳出来的窗口,怎么不可以关闭啊?

解决方案 »

  1.   

    应该重载 windowClosing(WindowEvent e) 
      

  2.   

    非你的 windowsClosing(WindowEvent e)
      

  3.   

    关闭窗口触发的是 windowClosing(WindowEvent e) 方法,
    而非 Win 的自定义方法 windowsClosing(WindowEvent e) . (多了个 's ')
      

  4.   

    yuzl32(Hello!有酒醉) ( 一星(中级)
    他已经重载了方法
    我认为是new TestFrame()错了,
    楼主Frame re=new TestFrame();试试
      

  5.   

    是多了个S,yuz132(Hello!有酒醉)
    谢谢了!
    改过来之后行了。