code: public static void invokeOnEventDispatchThread(Runnable runnable)
      {
          if (SwingUtilities.isEventDispatchThread())
          {
              runnable.run();
          }
          else
          {
              SwingUtilities.invokeLater(runnable);
          }
      }
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.invokeLater</code>
  
  @param runnable The runnable