我有一个父窗体(form1),还有二个子窗体(form2,form3)
我想用父窗体(form1)调用子窗体(form2),再通过子窗体(form2)中的按钮调用另一个子窗体(form3)
需要怎么做
我是个新手,谢谢大家帮个忙

解决方案 »

  1.   

    在form1中new一个form2,在form2中new一个form3.........
    最好把form2和form3设置成模态的。
      

  2.   

    我的代码是这样写的,单调FORM2、FORM3都可以,只要一用FORM2调FORM3就不成功,FORM3调不也来,系统也不报错。
    主页面的
    public class form1 extends JFrame {
    JDesktopPane desk      = null;
    JButton jButton1 = new JButton();private void jbInit() throws Exception {
    desk = new JDesktopPane();
    jButton1.setText("调用FORM2");
            jButton1.addActionListener(new form2_ActionAdapter(this));
    }
    void form2_actionPerformed(ActionEvent actionEvent) {
    form2 dlg = new form2();
      dlg.setClosable(true);
        desk.add(dlg);
        dlg.setVisible(true);
        try{
           dlg.setSelected(true);
        } catch(java.beans.PropertyVetoException ex) {
          System.out.println(ex.toString());
        }
    }
    }
    class form2_ActionAdapter implements ActionListener {
        form1 adaptee;    form2_ActionAdapter(form1 adaptee) {
            this.adaptee = adaptee;
        }
    public void actionPerformed(ActionEvent actionEvent) {
            adaptee.form2_actionPerformed(actionEvent);
        }
    }在FORM2的public class form2 extends JInternalFrame  {
    JButton jButton1 = new JButton();
    private void jbInit() throws Exception {
    jButton1.setText("调用FORM3");
            jButton1.addActionListener(new form3_ActionAdapter(this));
    }
    void form3_actionPerformed(ActionEvent actionEvent) {
    form1 a=new from1();
    form3 dlg = new form3();
      dlg.setClosable(true);
        a.desk.add(dlg);
        dlg.setVisible(true);
        try{
           dlg.setSelected(true);
        } catch(java.beans.PropertyVetoException ex) {
          System.out.println(ex.toString());
        }
    }
    }