Frame2 frame;frame.pack();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);

解决方案 »

  1.   

    Frame2 frame = new Frame2() ;呵呵,更正楼上的一行:)
      

  2.   

    show一下你要显示的界面就完了嘛
    或是按找二楼的用setVisible(true)使其可见,都行的
      

  3.   

    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    class Yourwindow extends Frame

      Yourwindow(String s, int a,int b)       //构造方法。
      { super(s);                             //名字是字符串s。
        setLayout(new GridLayout(1,1));// 把布局设置为GridLayout布局。
        setSize(a,b);               //把窗口的初始大小设置为a*b像素。
        setBackground(Color.white);      //把窗口的底色设置为白色。
    setVisible(false);          //把窗口设置为不可见的。
    pack();//用紧凑方式显示窗口。
      }  
    }
    public class Example15_2 extends Applet implements ActionListener
    { Yourwindow window1,window2 ;     //声明两个窗口对象。
      Button button1,button2,button3,button4;
      public void init()
      { button1=new Button("开南窗");    button2=new Button("开北窗");
        button3=new Button("关南窗");    button4=new Button("关北窗");
        window1=new Yourwindow("阳光之窗",60,60);//创建窗口
        window2=new Yourwindow("冰雪之窗",70,70);//创建窗口 
        button1.addActionListener(this);
        button2.addActionListener(this);
        button3.addActionListener(this);
        button4.addActionListener(this);
        add(button1);add(button2);add(button3);add(button4); 
     }
    public void actionPerformed(ActionEvent e)
     { if(e.getSource()==button1)
         { window1.setVisible(true);
         }
      else if(e.getSource()==button3)
         { window1.setVisible(false);
         }  
      else if(e.getSource()==button2)
         { window2.setVisible(true);
         }
      else if(e.getSource()==button4)
         { window2.setVisible(false);
         }  
     }
    }
      

  4.   

    private void ButtonActionPerformed(java.awt.event.ActionEvent evt) {
            new newFrame().show();
        }
    你只需要这样就可以了,如果要返回到上一级窗口的话就设置如下:
        private void exitForm(java.awt.event.WindowEvent evt) {
            setVisible(false);
            dispose();
        }