try { Thread.sleep(2000); } catch (InterruptedException e) { }  try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { curFrame.doDefaultCloseAction(); } }); } catch (Exception e) { e.printStackTrace(); }  try { Thread.sleep(2000); } catch (InterruptedException e) { } } }
        public void run() {          while (true) {            try {              SwingUtilities.invokeAndWait(new Runnable() {                  public void run() {                    curFrame = addWindow(false);                  }                });            } catch (Exception e) {              e.printStackTrace();            }            try {              Thread.sleep(2000);            } catch (InterruptedException e) {            }            try {              SwingUtilities.invokeAndWait(new Runnable() {                  public void run() {                    curFrame.doDefaultCloseAction();                  }                });            } catch (Exception e) {              e.printStackTrace();            }            try {              Thread.sleep(2000);            } catch (InterruptedException e) {            }          }        }