public void WindowClosing(WindowEvent e)
注意这个方法,是用户提交窗口管理命令去关闭窗口时调用的,只有在hide或者dispose方法调用以后才会关闭窗口
你可以用 WindowClosed这个方法看看
这个方法是窗口关闭以后调用
要不在 Frame1 f = new Frame1();以后加
f.setDefaultCloseOperation(JFrame .EXIT_ON_CLOSE );
这样肯定可以

解决方案 »

  1.   

    用frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);======================================================
    public void setDefaultCloseOperation(int operation)
    Sets the operation that will happen by default when the user initiates a "close" on this frame. You must specify one of the following choices: DO_NOTHING_ON_CLOSE (defined in WindowConstants): Don't do anything; require the program to handle the operation in the windowClosing method of a registered WindowListener object. 
    HIDE_ON_CLOSE (defined in WindowConstants): Automatically hide the frame after invoking any registered WindowListener objects. 
    DISPOSE_ON_CLOSE (defined in WindowConstants): Automatically hide and dispose the frame after invoking any registered WindowListener objects. 
    EXIT_ON_CLOSE (defined in JFrame): Exit the application using the System exit method. Use this only in applications. 
    The value is set to HIDE_ON_CLOSE by default. 
    =================================================================================