用JDialog弹出新的对话框,使用构造函数JDialog(Frame owner,String title)可以使被弹出的JFrame无效化吗?
怎么样在弹出的对话框中加入一个JButton的事件处理程序使得弹出对话框推出,并使原JFrame有效?

解决方案 »

  1.   

    原本不就是这样的吗?
    弹出dialog之后,frame就会无效化
    dialog消失了,frame就会有效啊        String message = "Line1\nLine2";
            JFrame frame = new JFrame("JFrame");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JComponent comp = new JTextArea();
            frame.getContentPane().add(comp, BorderLayout.CENTER);
            frame.setSize(300, 300);
            
            frame.setVisible(true);        int answer = JOptionPane.showConfirmDialog(frame, message);
            if (answer == JOptionPane.YES_OPTION) {
            } else if (answer == JOptionPane.NO_OPTION) {
            }
      

  2.   

    不对
    我的意思是说
    通过继承JDialog而得到的弹出对话框类,弹出后两个对话框都有效,如何让原来的无效?
      

  3.   

    创建对话框时用构造函数JDialog(JFrame owner,boolean key)
    owner 是要弹出对话框而自己无效的Frame,key用来设置对话框弹出时它的父窗体(owner)是否有效.true时就是你想要的效果
      

  4.   

    cat_871017(零下九度) 的回答完全正确.这样的处理的效果是迫使user先对对话框予以
    处理,然后才能处理 frame