code: public static void invokeOnEventDispatchThreadSync(Runnable runnable)
      {
          if (SwingUtilities.isEventDispatchThread())
          {
              runnable.run();
          }
          else
          {
              try
              {
                  SwingUtilities.invokeAndWait(runnable);
              }
              catch (InvocationTargetException e)
              {
                  throw new RuntimeException(e);
              }
              catch (InterruptedException e)
              {
                  Thread.currentThread().interrupt();
              }
          }
      }
docs: Execute the given runnable on the event dispatch thread. <br>
  <br>
  If the calling thread is the EDT, then the runnable will be executed
  directly. Otherwise, it will be executed with
  <code>SwingUtilities.invokeAndWait</code>
  
  @param runnable The runnable
  @throws RuntimeException If the given runnable causes a RuntimeException