src/Pure/General/swing.scala
changeset 29649 8b0c1397868e
parent 29202 2454172eddae
child 29777 f3284860004c
--- a/src/Pure/General/swing.scala	Wed Jan 28 10:43:31 2009 +0100
+++ b/src/Pure/General/swing.scala	Wed Jan 28 11:36:45 2009 +0100
@@ -10,9 +10,13 @@
 
 object Swing
 {
-  def now(body: => Unit) =
-    SwingUtilities.invokeAndWait(new Runnable { def run = body })
+  def now(body: => Unit) {
+    if (SwingUtilities.isEventDispatchThread) body
+    else SwingUtilities.invokeAndWait(new Runnable { def run = body })
+  }
 
-  def later(body: => Unit) =
-    SwingUtilities.invokeLater(new Runnable { def run = body })
+  def later(body: => Unit) {
+    if (SwingUtilities.isEventDispatchThread) body
+    else SwingUtilities.invokeLater(new Runnable { def run = body })
+  }
 }