- Issue 106: Add splash screen just under progress bar, and load all cards at startup.

This commit is contained in:
Braids
2011-08-19 02:22:03 +00:00
parent c260a283cd
commit fdb1199223
8 changed files with 400 additions and 109 deletions

View File

@@ -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.
*