mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
- Issue 106: Add splash screen just under progress bar, and load all cards at startup.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package net.slightlymagic.braids.util;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
* Some general-purpose functions.
|
||||
*/
|
||||
@@ -39,9 +42,36 @@ public final class UtilFunctions {
|
||||
exn.setStackTrace(slice(new StackTraceElement[len], trace, 1));
|
||||
throw exn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Invoke the given Runnable in an Event Dispatch Thread and wait for it
|
||||
* to finish; but <B>try to use SwingUtilities.invokeLater instead whenever
|
||||
* feasible.</B>
|
||||
*
|
||||
* Exceptions generated by SwingUtilities.invokeAndWait (if used), are
|
||||
* rethrown as RuntimeExceptions.
|
||||
*
|
||||
* @see javax.swing.SwingUtilities#invokeLater(Runnable)
|
||||
*
|
||||
* @param proc the Runnable to run
|
||||
*/
|
||||
public static void invokeInEventDispatchThreadAndWait(final Runnable proc) {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
// Just run in the current thread.
|
||||
proc.run();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(proc);
|
||||
} catch (InterruptedException exn) {
|
||||
throw new RuntimeException(exn);
|
||||
} catch (InvocationTargetException exn) {
|
||||
throw new RuntimeException(exn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an array from the (rest of) an iterator's output;
|
||||
* this function is horribly inefficient.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user