invokelater only the startwork

This commit is contained in:
Honfika
2013-11-14 00:06:45 +01:00
parent f5effd21f2
commit e918209716
2 changed files with 13 additions and 1 deletions
@@ -151,7 +151,7 @@ public class Main {
public static void startWork(final String name, final int percent, final Runnable cancelCallback) {
working = true;
View.execInEventDispatch(new Runnable() {
View.execInEventDispatchLater(new Runnable() {
@Override
public void run() {
if (mainFrame != null) {
@@ -215,6 +215,18 @@ public class View {
}
public static void execInEventDispatch(Runnable r) {
if (SwingUtilities.isEventDispatchThread()) {
r.run();
} else {
try {
SwingUtilities.invokeAndWait(r);
} catch (InterruptedException | InvocationTargetException ex) {
Logger.getLogger(View.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public static void execInEventDispatchLater(Runnable r) {
if (SwingUtilities.isEventDispatchThread()) {
r.run();
} else {