Dialog1.setVisible(true);
Dialog1.show();
这两个不行吗?
如果不是,请把问题说清楚。

解决方案 »

  1.   

    某Window上弹出某Dialog操作完再继续Widow。
      

  2.   

    如果是想设置Dialog为模态对话框,这样:
    Dialog.setModal(true);
      

  3.   

    你的意思是?
      Dialog.setModal(true);
      Dialog.setVisible(true);
      

  4.   

    我不知道你的什么调用的。
    Kinescopedlg kinescopedlg = new Kinescopedlg(this);
    Dimension dlgSize = kinescopedlg.getPreferredSize();
    Dimension frmSize = getSize();
    Point loc = getLocation();
    kinescopedlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    kinescopedlg.setModal(true);
    kinescopedlg.show();
      

  5.   

    /*DialogTest.java*/import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class frame1 extends JFrame implements ActionListener
    {
       JButton button;
       JTextField textfield;
       frame1()
       {
          button=new JButton("b");
          textfield=new JTextField();
          Container con=getContentPane();
          setSize(100,100);
          con.setLayout(new GridLayout());
          con.add(button);
          con.add(textfield);
          setVisible(true);
          addWindowListener(new WindowAdapter()
          {
             public void windowClosing()
             {
                System.exit(0);
             }
          });
       }
       public void actionPerformed(ActionEvent e)
       {
          if (e.getSource()==button)
          {
              dialog1 d=new dialog1(this,"test");
              textfield.setText("sdfadsfa.\n");
          }
       }
    }class dialog1 extends JDialog implements ActionListener
    {
       JButton button;
       dialog1(JFrame f,String s)
       {
          super(f,s);
          button=new JButton("b");
          Container con=getContentPane();
          con.setSize(100,100);
          con.setLayout(new GridLayout(2,2));
          con.add(button);
          setModal(true);
          setVisible(true);
       }
       public void actionPerformed(ActionEvent e)
       {
          if (e.getSource()==button)
          {
             dispose();
          }
       }
    }
    class DialogTest
    {
       public static void main(String [] args)
       {
          frame1 f=new frame1();
       }
    }哪里错了?
      

  6.   

    show 和 setVisible 有何区别?
      

  7.   

    问问题要问的明确点。dialog.domodal()  ?
      

  8.   

    上面这段代码的目的是要测试:    构造一个Frame,Frame上的按键,点击后弹出对话框,对话框关闭后textfield显示出字符。    但是有错。(不是指GridLayout)    谢谢了。
      

  9.   

    呵呵,你的frame1和dialog1里的button都没有作addActionListener(this),按下去当然是没反应的,还有DialogTest要是public的才能运行
      

  10.   

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;class frame1 extends JFrame implements ActionListener
    {
       JButton button;
       JTextField textfield;
       frame1()
       {
          button=new JButton("b");
          button.addActionListener(this);
          textfield=new JTextField();
          Container con=getContentPane();
          setSize(100,100);
          con.setLayout(new FlowLayout());
          con.add(button);
          con.add(textfield);
          setVisible(true);
          addWindowListener(new WindowAdapter()
          {
             public void windowClosing()
             {
                System.exit(0);
             }
          });
       }
       public void actionPerformed(ActionEvent e)
       {
          if (e.getSource()==button)
          {
              dialog1 d=new dialog1(this,"test");
              textfield.setText("sdfadsfa.\n");
          }
       }
    }class dialog1 extends JDialog implements ActionListener
    {
       JButton button;
       dialog1(JFrame f,String s)
       {
          super(f,s);
          button=new JButton("b");
          button.addActionListener(this);
          Container con=getContentPane();
          con.setSize(100,100);
          con.setLayout(new GridLayout(2,2));
          con.add(button);
          setModal(true);
          setVisible(true);
       }
       public void actionPerformed(ActionEvent e)
       {
          if (e.getSource()==button)
          {
             setVisible(false);
          }
       }
    }public class DialogTest
    {
       public static void main(String [] args)
       {
          frame1 f=new frame1();
       }
    }这样似乎还是不行啊!