本人编写两个窗体,分别在不同的JAVA文件里,请问怎样通过时间触发将两了窗体连接起来.比如说点击第一个窗体的按钮,第二个窗体弹出.请指教 谢谢

解决方案 »

  1.   

    这我知道 但是如何让弹出第2个窗口
    Object obj=e.getSource();
    if (obj==button1)
    {

    }
    打括号里语句怎么写~~
      

  2.   

    不知道我实现的效果是你想要的不,代码如下
    窗体1
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class test2 extends JFrame{
      JPanel jPanel1 = new JPanel();
      JButton jButton1 = new JButton();  public test2() {
        try {
          jbInit();
          this.setSize(400,300);
          this.show();
        }
        catch(Exception e) {
          e.printStackTrace();
        }  }
      public static void main(String[] args) {
        test2 test21 = new test2();
      }
      private void jbInit() throws Exception {
        jButton1.setText("jButton1");
        jButton1.addActionListener(new test2_jButton1_actionAdapter(this));
        this.getContentPane().add(jPanel1, BorderLayout.CENTER);
        jPanel1.add(jButton1, null);
      }  void jButton1_actionPerformed(ActionEvent e) {
        new test3();
      }}class test2_jButton1_actionAdapter implements java.awt.event.ActionListener {
      test2 adaptee;  test2_jButton1_actionAdapter(test2 adaptee) {
        this.adaptee = adaptee;
      }
      public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
      }
    }
      

  3.   

    窗体2
    import javax.swing.JFrame;public class test3 extends JFrame{
      public test3() {
        this.setSize(200,100);
        this.show();
      }
      public static void main(String[] args) {
        test3 test31 = new test3();
      }}