equal
deleted
inserted
replaced
|
1 /* Title: Pure/General/swing_thread.scala |
|
2 Author: Makarius |
|
3 |
|
4 Evaluation within the AWT/Swing thread. |
|
5 */ |
|
6 |
|
7 package isabelle |
|
8 |
|
9 import javax.swing.SwingUtilities |
|
10 |
|
11 object Swing_Thread |
|
12 { |
|
13 def now[A](body: => A): A = { |
|
14 var result: Option[A] = None |
|
15 if (SwingUtilities.isEventDispatchThread) { result = Some(body) } |
|
16 else SwingUtilities.invokeAndWait(new Runnable { def run = { result = Some(body) } }) |
|
17 result.get |
|
18 } |
|
19 |
|
20 def later(body: => Unit) { |
|
21 if (SwingUtilities.isEventDispatchThread) body |
|
22 else SwingUtilities.invokeLater(new Runnable { def run = body }) |
|
23 } |
|
24 } |