Swing invokeLater never shows up, invokeAndWait throws error. What can I do?
Posted
by Geo
on Stack Overflow
See other posts from Stack Overflow
or by Geo
Published on 2010-06-14T18:05:21Z
Indexed on
2010/06/14
18:12 UTC
Read the original article
Hit count: 184
I have this code:
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
try {
dialog.handleDownload();
} catch (IOException io) {
io.printStackTrace();
}
}
});
} catch(Exception io) { io.printStackTrace(); }
in the handleDownload
I'm reading an inputstream, calculating a progress bar's value, and setting it to that. So, when I click a button, a new JFrame opens up and does all the stuff I wrote above.
If I have the dialog.handleDownload
by itself ( in no SwingUtilities method ), it freezes until the operation is finished. If I add it in a invokeLater
it's closed very fast ( I can't see anything, and the operation is not finished ). If I add it in a invokeAndWait
I get the invokeAndWait
cannot be called from the event dispatcher thread error. What should I do?
© Stack Overflow or respective owner