code: public static void runInEventDispatcherThread(Runnable runnable, Boolean wait) {
  
          Assert.notNull(runnable, "runnable");
          Assert.notNull(wait, "wait");
  
          if (EventQueue.isDispatchThread()) {
              runnable.run();
          } else if (wait) {
              try {
                  EventQueue.invokeAndWait(runnable);
              } catch (InterruptedException e) {
                  throw new RuntimeException(e);
              } catch (InvocationTargetException e) {
                  throw new RuntimeException(e);
              }
          } else {
              EventQueue.invokeLater(runnable);
          }
      }
docs: Ensures the given runnable is executed into the event dispatcher thread.
  
  @param runnable
  the runnable.
  @param wait
  whether should wait until execution is completed.