SwingXUtilities { public static <T> T invokeAndWait(Callable<T> callable) throws InterruptedException, InvocationTargetException { try { return invokeLater(callable).get(); } catch (ExecutionException e) { Throwable t = e.getCause(); if (t instanceof RuntimeException) { throw (RuntimeException) t; } else if (t instanceof InvocationTargetException) { throw (InvocationTargetException) t; } else { throw new InvocationTargetException(t); } } } private  SwingXUtilities(); static void updateMnemonicBinding(JComponent c, String pressed); static void updateMnemonicBinding(JComponent c, String pressed, String released); static void setComponentTreeEnabled(Component c, boolean enabled); static void setComponentTreeLocale(Component c, Locale locale); static void setComponentTreeBackground(Component c, Color color); static void setComponentTreeForeground(Component c, Color color); static void setComponentTreeFont(Component c, Font font); static void setHtmlFont(HTMLDocument doc, Font font); static void updateAllComponentTreeUIs(); static void updateAllComponentTreeUIs(Window window); static FutureTask<T> invokeLater(Callable<T> callable); static T invokeAndWait(Callable<T> callable); @SuppressWarnings("unchecked") static T getAncestor(Class<T> clazz, Component c); static boolean isDescendingFrom(Component focusOwner, Component parent); static boolean isUIInstallable(Object property); static void setLeadAnchorWithoutSelection(
            ListSelectionModel selectionModel, int lead, int anchor); static boolean shouldIgnore(MouseEvent mouseEvent,
            JComponent component); static int loc2IndexFileList(JList list, Point point); static void adjustFocus(JComponent component); static int convertModifiersToDropAction(int modifiers,
            int sourcActions);  }
@Test public void testInvokeAndWait() throws Exception { assertThat(SwingUtilities.isEventDispatchThread(), is(false)); Callable<Boolean> callable = new Callable<Boolean>() { @Override public Boolean call() throws Exception { assertThat(SwingUtilities.isEventDispatchThread(), is(true)); Thread.sleep(1000); return true; } }; long start = System.currentTimeMillis(); assertThat(SwingXUtilities.invokeAndWait(callable), is(true)); assertThat((System.currentTimeMillis() - start) > 1000, is(true)); }