不用windowClosing()啊,如果你点关,当前的Frame自己就会关回到主窗口。如果你再加一个“退出”的按钮,只用在Button中加入ActionListner,实现actionPerformed(ActionEvent e)就行了,如下:
JButton exit = new JButton("EXIT");
    exit.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e){
        dispose(); // Closes the dialog
      }
    });