请问各位 如何在关闭子窗口时 不同时关闭主窗口阿!!
谢过各位了!!

解决方案 »

  1.   

    你使用的是什么语句关闭子窗口的,在子窗口中调用dispose()可以在内存中销毁子窗口,调用setVisible(false)可以隐藏子窗口,随便哪个语句都不可能关闭主程序的,除非使用System.exit(0)
      

  2.   

    不知道是不是你要求的.import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;import javax.swing.JButton;
    import javax.swing.JFrame;public class MyJFrame extends JFrame {    private static final long serialVersionUID = 1L;    /**
         * @param args
         */
        public static void main(String[] args) {
            
            JButton button = new JButton("button");
            button.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e) {
                    JFrame newFrame = new JFrame("newFrame");
                    newFrame.setSize(200, 100);
                    newFrame.setVisible(true);
                }
            });
            
            MyJFrame frame = new MyJFrame();
            frame.setSize(400, 300);
            frame.add(button);
            frame.setVisible(true);
        }}