有什么方法能显示第2个Frame?
在第一个Frame中设置按钮
点击显示第二个Frame有这种方法么?

解决方案 »

  1.   

    在按钮事件中将第二个窗口显示就行了
    frame2.setVisible(true);
      

  2.   

    你说的是不是 你想在第一个FRAME中,设置一个按钮,点击按钮,显示第二个FRAME?
      

  3.   

    现在 show() 方法 好像换成了 SETVISIBLE()方法
      

  4.   

    首先,在你的第一个类开头添加一个ActionListener接口
       xxx implements ActionListener;
    然后就为你的按钮添加动作
     public void actionPerformed(ActionEvent e) {
    新增一个你要打开窗口的一个对象
       xxx a=new xxx();
    然后显示这个对象的窗口
       a.setVisible(true);
    }
     最后,就是在控件添加时注册ActionListener
      jButtonx.addActionListener(this);
     这就可以
      

  5.   

    真接生成第二个frame对象,然后用对象.setVisible(true)就可以了,如果要关闭当前的frame的话,直接用this.dispose()方法关闭
      

  6.   

    按钮事件添加
    //frame frame2=new frame();
    //frame2.setVisible(true); 
      

  7.   

    给你一个例子,好好研究一下
    import java.awt.*;
    import java.awt.event.*;public class DialogTest
        extends Frame {
      private Dialog d;
      public DialogTest() {
        Button b;
        setBounds(100, 100, 600, 400);
        b = new Button("NEW");
        d = new Dialog(this, "NEW"); //无模式的 SubDialog
        d.setBounds(150, 150, 300, 200);
        b.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            d.setVisible(true);
          }
        });
        d.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            d.setVisible(false);
          }
        });
        addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
        add("South", b);
        setVisible(true);
      }
        public static void main(String[] args) {
        new DialogTest();
      }
    }