同意楼上!
<<java21天自学通>><<java技术内幕〉

解决方案 »

  1.   

    /**
    *NewWindow.java
    */import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;public class NewWindow extends JFrame implements ActionListener
           {
            private JButton next;
            JPanel pane;
            public NewWindow()
                  { 
                   super("Window");
                   setSize(300,500);
                   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   
                   next = JButton("下一步");
                   pane = new JPanel();
                        pane.addActionListener(this);
                        pane.add(next);
                   setContentPane(pane);
                   }
              public static void main(String[] args)
                    {
                     NewWindow window = new NewWindow();
                               window.show();
                     }
              public void actionPerformed(ActionEvent evt)
                    {
                    new NewWindow(); //你可以试试生成自身对像. 
                    }
             }
     
    也可以再做一个类似的类然后生成本类对像就可以,
    当然你这个类具有其它一些别的功能感觉好像是在做一个向导之类的东西。我在网吧上网 没有调试运行有错与我联系给我发短信。
      

  2.   

    在第一个Jframe的下一步按钮的监听中new第二个Jframe,在第二个Jframe的下一步按钮的监听中new第三个Jframe,以此类推,但是不能关闭前一个窗口
    要注意的是一定不能system.exit(0),这个是把整个程序都关闭的命令,可以在第二三四个JFrame中不加入system.exit(0),这样关闭当前窗口的时候就不会把整个程序关闭了
    这样不行吗?????
      

  3.   

    上个帖子不是给你写了吗?你看了不是你要的效果?再贴一下,否则白写了,哈哈,抢分无极限import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.*;
    import java.awt.event.*;public class Test extends JFrame{
    JButton a;
    static Test frame;
    public Test(){
    Container cp = getContentPane();
    a = new JButton("&micro;&Uacute;&Ograve;&raquo;&sup2;&frac12;");
    a.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
    Text2 frame2 = new Text2();
    frame2.setVisible(true);
    frame2.setSize(200,200);
    frame2.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e){
    System.exit(0);
    }
    }); frame.setVisible(false);
    }
    });
    cp.add(a);
    pack();
    repaint();
    } public static void main(String[] args){
    frame = new Test();
    frame.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e){
    System.exit(0);
    }
    });
    frame.setSize(200,200);
    frame.setVisible(true);
    }
    }class Text2 extends JFrame{
    JButton a ;
    public Text2(){
    Container cp = getContentPane();
    a = new JButton("&micro;&Uacute;&para;&thorn;&sup2;&frac12;");
    cp.add(a);
    pack();
    repaint();
    }
    }