singleton模式???
不用吧???
判断子窗体关闭的事件里控制按钮是否可用就行了

解决方案 »

  1.   

    随便改了一下,功能能出来:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;class Main extends JFrame implements ActionListener 
    {
       private JPanel pan1;
       private JButton Jb1,Jb2;
       private Container con;
       private JFrame newFrom;
       private ActionEvent aEvent;   public Main()
       {
         super("test");
         setDefaultCloseOperation(EXIT_ON_CLOSE);
                    buildFrame();
                      addAction();
       }   protected void newFrom(ActionEvent e)
       {
                    newFrom=new JFrame();
                    this.aEvent = e;
                    newFrom.addWindowListener(new WindowAdapter(){
                    public void windowClosing(WindowEvent e) {
                    newFrom.setVisible(false);         
                    ((JButton)aEvent.getSource()).setEnabled(true);
                    }
                    });
                    newFrom.setTitle("新窗体");
                    newFrom.setSize(300,300);
                    newFrom.show();
       }   protected void buildFrame()
       {
                 con=getContentPane();
                 pan1=new JPanel();
                 Jb1=new JButton("1");
                 Jb2=new JButton("2");
                 pan1.setLayout(new GridLayout(2,1));
              pan1.add(Jb1);
              pan1.add(Jb2);
              con.add(pan1);
          setSize(400,400);
              show();
       }
       protected void addAction()
       {
                   Jb1.addActionListener(this);
                    Jb2.addActionListener(this);
       }
       public static void main(String args[])
       {
               new Main();
       }   public void actionPerformed(ActionEvent e) 
       {
                    newFrom(e);
                    ((JButton)e.getSource()).setEnabled(false);
       }
    }