我在程序退出时添加一个JOptionPane组件  当我点击它的"否"或者"取消"按钮时怎么才能回到它的父窗口

解决方案 »

  1.   

    在创建窗口对象先使用下面语句aFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
    在窗口的Closing事件中写成以下方法(或在菜单的“退出”中):    private void formWindowClosing(java.awt.event.WindowEvent evt)
        {
            int sel = JOptionPane.showConfirmDialog(null,"你确认要退出吗");
            if(sel==JOptionPane.YES_OPTION)
                System.exit(0);
        }
      

  2.   

    yes就推出,剩下的不管就回父了