按我的理解,你所说的子窗口应该是在主窗口所在的类中实例化的吧。直接在主窗口frameMain的windows_closing(WindowEvent e)中加入:
frameLog.dispose();

解决方案 »

  1.   

    你确定在加入了主窗口关闭时候会调用frameLog的this_windows_closeing事件。
    也就是说frameLog.dispose()会通知frameLog执行关闭动作。
      

  2.   

    不可以。执行时候抱错:
    Exception occurred during event dispatching:java.lang.ClassCastException: java.util.Hashtable$Entry at maxclient.FrameMain.this_windowClosing(FrameMain.java:183) at maxclient.FrameMain$12.windowClosing(FrameMain.java:170) at java.awt.Window.processWindowEvent(Window.java:798) at javax.swing.JFrame.processWindowEvent(JFrame.java:241) at java.awt.Window.processEvent(Window.java:774) at java.awt.Component.dispatchEventImpl(Component.java:2595) at java.awt.Container.dispatchEventImpl(Container.java:1213) at java.awt.Window.dispatchEventImpl(Window.java:912) at java.awt.Component.dispatchEvent(Component.java:2499) at java.awt.EventQueue.dispatchEvent(EventQueue.java:319) at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
      

  3.   

    那就这样吧:
    frameMain.addWindowListener(new WindowAdapter(){
         public void windowClosing(WindowEvent e){
             System.exit(0);
         }
    });
      

  4.   

    dispose can be performed ,but it doese not result in the windows closing event of the child frame.
     
    to kuky121: 你的方法不可以,是要传递主窗口的windows event to 子窗口
      

  5.   

    关闭主窗体用 System.exit(0);关闭子窗体用 setVisible(False);
      

  6.   

    to tanguanghbin:
     the problem is the program won't call this_windows_closing event of the sub frame while the System.exit(0) is called in the main Frame.