test/java/awt/regtesthelpers/Util.java

Print this page

        

*** 74,89 **** import java.util.concurrent.atomic.AtomicBoolean; public final class Util { private Util() {} // this is a helper class with static methods :) /* * @throws RuntimeException when creation failed */ public static Robot createRobot() { try { ! return new Robot(); } catch (AWTException e) { throw new RuntimeException("Error: unable to create robot", e); } } --- 74,94 ---- import java.util.concurrent.atomic.AtomicBoolean; public final class Util { private Util() {} // this is a helper class with static methods :) + private volatile static Robot robot; + /* * @throws RuntimeException when creation failed */ public static Robot createRobot() { try { ! if (robot == null) { ! robot = new Robot(); ! } ! return robot; } catch (AWTException e) { throw new RuntimeException("Error: unable to create robot", e); } }
*** 198,208 **** } } return false; } ! public static void waitForIdle(final Robot robot) { robot.waitForIdle(); } public static Field getField(final Class klass, final String fieldName) { return AccessController.doPrivileged(new PrivilegedAction<Field>() { --- 203,216 ---- } } return false; } ! public static void waitForIdle(Robot robot) { ! if (robot == null) { ! robot = createRobot(); ! } robot.waitForIdle(); } public static Field getField(final Class klass, final String fieldName) { return AccessController.doPrivileged(new PrivilegedAction<Field>() {