invokeandwait

Returning values from Swing using invokeAndWait

I've been using the following approach to create components and return values from Swing to/from outside the EDT. For instance, the following method could be an extension to JFrame, to create a JPanel and add it to the parent JFrame: public JPanel threadSafeAddPanel() { final JPanel[] jPanel = new JPanel[1]; try { Even...

Waiting for invokeLater() to be called

Is there a more elegant way to do what I'm doing below? That is, is there a more elegant way than polling and sleeping, polling and sleeping, and so on to know when a Runnable.run() method has been called via invokeLater()? private int myMethod() { final WaitForEventQueue waitForQueue = new WaitForEventQueue(); EventQueue.invok...