code: public static void invokeSwingAction(final Runnable runnable) {
          if (SwingUtilities.isEventDispatchThread()) {
              runnable.run();
          } else {
              SwingUtilities.invokeLater(runnable);
          }
      }
docs: Invokes a {@link Runnable} as soon as possible. If this is the swing event dispatch thread, it will be run now,
  or else later using {@link SwingUtilities#invokeLater(Runnable)}
  
  @param runnable