equal
deleted
inserted
replaced
8 |
8 |
9 import javax.swing.SwingUtilities |
9 import javax.swing.SwingUtilities |
10 |
10 |
11 object Swing |
11 object Swing |
12 { |
12 { |
13 def now(body: => Unit) { |
13 def now[A](body: => A): A = { |
14 if (SwingUtilities.isEventDispatchThread) body |
14 var result: Option[A] = None |
15 else SwingUtilities.invokeAndWait(new Runnable { def run = body }) |
15 if (SwingUtilities.isEventDispatchThread) { result = Some(body) } |
|
16 else SwingUtilities.invokeAndWait(new Runnable { def run = { result = Some(body) } }) |
|
17 result.get |
16 } |
18 } |
17 |
19 |
18 def later(body: => Unit) { |
20 def later(body: => Unit) { |
19 if (SwingUtilities.isEventDispatchThread) body |
21 if (SwingUtilities.isEventDispatchThread) body |
20 else SwingUtilities.invokeLater(new Runnable { def run = body }) |
22 else SwingUtilities.invokeLater(new Runnable { def run = body }) |