views:

50

answers:

1

could return boolean? I want to new a JFrame if the JFrame not exsits,but not to new if exsits. I creat a Map to save JFrame's name.

A: 

You're looking for a singleton frame. It would look somewhat like

class MyFrame extends JFrame {

   private static MyFrame frame;

   private  MyFrame() {}

   public static MyFrame getInstance() {

      if ( frame == null ) {
          frame = new MyFrame();
      }
      return frame;

   }


}
eugener