result for Swing.now;
authorwenzelm
Sun, 22 Feb 2009 20:37:18 +0100
changeset 29777 f3284860004c
parent 29776 8f2eb202ae94
child 30101 5c6efec476ae
result for Swing.now;
src/Pure/General/swing.scala
--- a/src/Pure/General/swing.scala	Sat Feb 21 18:06:17 2009 +0100
+++ b/src/Pure/General/swing.scala	Sun Feb 22 20:37:18 2009 +0100
@@ -10,9 +10,11 @@
 
 object Swing
 {
-  def now(body: => Unit) {
-    if (SwingUtilities.isEventDispatchThread) body
-    else SwingUtilities.invokeAndWait(new Runnable { def run = body })
+  def now[A](body: => A): A = {
+    var result: Option[A] = None
+    if (SwingUtilities.isEventDispatchThread) { result = Some(body) }
+    else SwingUtilities.invokeAndWait(new Runnable { def run = { result = Some(body) } })
+    result.get
   }
 
   def later(body: => Unit) {