40 |
|
|
41 |
import gnu.java.awt.ClasspathToolkit; |
import gnu.java.awt.ClasspathToolkit; |
42 |
|
|
43 |
|
import java.lang.reflect.InvocationTargetException; |
44 |
import java.awt.event.InputEvent; |
import java.awt.event.InputEvent; |
45 |
import java.awt.image.BufferedImage; |
import java.awt.image.BufferedImage; |
46 |
import java.awt.peer.RobotPeer; |
import java.awt.peer.RobotPeer; |
54 |
* |
* |
55 |
* Since Robot generates native windowing system events, rather than |
* Since Robot generates native windowing system events, rather than |
56 |
* simply inserting {@link AWTEvents} on the AWT event queue, its use |
* simply inserting {@link AWTEvents} on the AWT event queue, its use |
57 |
* is not restricted to Java programs. It can be to programatically |
* is not restricted to Java programs. It can be used to |
58 |
* drive any graphical application. |
* programatically drive any graphical application. |
59 |
* |
* |
60 |
* This implementation requires an X server that supports the XTest |
* This implementation requires an X server that supports the XTest |
61 |
* extension. |
* extension. |
385 |
} |
} |
386 |
|
|
387 |
/** |
/** |
388 |
* Wait until the event dispatch thread is idle. |
* Wait until all events currently on the event queue have been |
389 |
|
* dispatched. |
390 |
*/ |
*/ |
391 |
public void waitForIdle () |
public void waitForIdle () |
392 |
{ |
{ |
395 |
+ "the event dispatch thread"); |
+ "the event dispatch thread"); |
396 |
|
|
397 |
EventQueue q = Toolkit.getDefaultToolkit ().getSystemEventQueue (); |
EventQueue q = Toolkit.getDefaultToolkit ().getSystemEventQueue (); |
398 |
|
try |
399 |
while (q.peekEvent () != null) |
{ |
400 |
|
q.invokeAndWait (new Runnable () { public void run () { } }); |
401 |
|
} |
402 |
|
catch (InterruptedException e) |
403 |
|
{ |
404 |
|
System.err.println ("Robot: waitForIdle interrupted"); |
405 |
|
} |
406 |
|
catch (InvocationTargetException e) |
407 |
{ |
{ |
408 |
try |
System.err.println ("Robot: waitForIdle cannot invoke target"); |
|
{ |
|
|
wait (); |
|
|
} |
|
|
catch (InterruptedException e) |
|
|
{ |
|
|
System.err.println ("Robot: waitForIdle interrupted"); |
|
|
} |
|
409 |
} |
} |
410 |
} |
} |
411 |
|
|