List of usage examples for java.lang Thread notifyAll
@HotSpotIntrinsicCandidate public final native void notifyAll();
From source file:au.com.jwatmuff.eventmanager.util.GUIUtils.java
/** * Makes a frame visible and blocks the caller until the frame is closed. * //from w ww.j a va 2 s.c o m * @param frame */ public static void runModalJFrame(final JFrame frame) { // there may be a much better way of implementing this, i don't know.. class RunningFlag { boolean value = true; } final RunningFlag flag = new RunningFlag(); final Thread t = Thread.currentThread(); try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent arg0) { synchronized (t) { flag.value = false; t.notifyAll(); } } }); frame.setVisible(true); } }); synchronized (t) { while (flag.value == true) try { t.wait(); } catch (InterruptedException e) { } } } catch (InterruptedException e) { log.error(e); } catch (InvocationTargetException e2) { log.error(e2); } }