I have the following fun which will be executed by non event dispatching thread. In the middle of thread, I want a
Launch the JOptionPane from the EDT, and pass the value back with a FutureTask.
public int fun()
{
FutureTask dialogTask = new FutureTask(new Callable()
{
@Override public Integer call()
{
return JOptionPane.showConfirmDialog(SaveToCloudJDialog.this, message, title, JOptionPane.YES_NO_OPTION);
}
});
SwingUtilities.invokeLater(dialogTask);
int choice = dialogTask.get();
}
Credit to jtahlborn How to pass results from EDT back to a different thread?