code: private void invokeAndWait(Runnable run) {
          if(!SwingUtilities.isEventDispatchThread()) {
              try {
                  SwingUtilities.invokeAndWait(run);
              } catch(Exception e) {
                  // shouldn't happen
                  e.printStackTrace();
              }
          } else {
              run.run();
          }
      }
docs: If not in the event thread run via SwingUtilities.invokeAndWait()