如果有一个窗口A,里面能通过菜单项Item响应窗口B,为什么我关闭窗口B时,也将窗口A也关闭了.
     实现关闭窗口的方法都是继承JFrame中的this.setDefaultCloseOperation(EXIT_ON_CLOSE);
     窗口A与B放在不同的包中;

解决方案 »

  1.   

    非主窗口都不要写 setDefaultCloseOperation(EXIT_ON_CLOSE),因为执行了这句的窗口一旦关闭,整个程序就退出了。不管你哪个包里面。
      

  2.   

    this.setDefaultCloseOperation(EXIT_ON_CLOSE); 修改为:
    this.setDefaultCloseOperation(HIDDEN_ON_CLOSE); 但不是一劳永逸的办法
      

  3.   

    A,B为窗口
    A:this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);B:setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);