< prev index next >

test/jdk/java/awt/Focus/ModalExcludedWindowClickTest/ModalExcludedWindowClickTest.java

Print this page




  96     void test() {
  97         clickOn(button);
  98         waitForIdle();
  99         if (!actionPerformed) {
 100             throw new RuntimeException("Test failed!");
 101         }
 102         System.out.println("Test passed.");
 103     }
 104 
 105     void clickOn(Component c) {
 106         Point p = c.getLocationOnScreen();
 107         Dimension d = c.getSize();
 108 
 109         System.out.println("Clicking " + c);
 110 
 111         if (c instanceof Frame) {
 112             robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + ((Frame)c).getInsets().top/2);
 113         } else {
 114             robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
 115         }
 116         waitForIdle();
 117         robot.mousePress(InputEvent.BUTTON1_MASK);
 118         robot.delay(50);
 119         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 120         waitForIdle();
 121     }
 122     void waitTillShown(Component c) {
 123         while (true) {
 124             try {
 125                 Thread.sleep(100);
 126                 Point p = c.getLocationOnScreen();
 127                 if (p != null)
 128                     break;
 129             } catch (InterruptedException e) {
 130                 throw new RuntimeException(e);
 131             } catch (IllegalComponentStateException e) {}
 132         }
 133     }
 134     void waitForIdle() {
 135         try {
 136             robot.waitForIdle();
 137             EventQueue.invokeAndWait( new Runnable() {
 138                     public void run() {} // Dummy implementation
 139                 });
 140         } catch(InterruptedException ie) {
 141             System.out.println("waitForIdle, non-fatal exception caught:");
 142             ie.printStackTrace();
 143         } catch(InvocationTargetException ite) {
 144             System.out.println("waitForIdle, non-fatal exception caught:");
 145             ite.printStackTrace();
 146         }
 147 
 148         // wait longer...


  96     void test() {
  97         clickOn(button);
  98         waitForIdle();
  99         if (!actionPerformed) {
 100             throw new RuntimeException("Test failed!");
 101         }
 102         System.out.println("Test passed.");
 103     }
 104 
 105     void clickOn(Component c) {
 106         Point p = c.getLocationOnScreen();
 107         Dimension d = c.getSize();
 108 
 109         System.out.println("Clicking " + c);
 110 
 111         if (c instanceof Frame) {
 112             robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + ((Frame)c).getInsets().top/2);
 113         } else {
 114             robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
 115         }

 116         robot.mousePress(InputEvent.BUTTON1_MASK);

 117         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 118         waitForIdle();
 119     }
 120     void waitTillShown(Component c) {
 121         while (true) {
 122             try {
 123                 Thread.sleep(100);
 124                 c.getLocationOnScreen();
 125                 break;

 126             } catch (InterruptedException e) {
 127                 throw new RuntimeException(e);
 128             } catch (IllegalComponentStateException e) {}
 129         }
 130     }
 131     void waitForIdle() {
 132         try {
 133             robot.waitForIdle();
 134             EventQueue.invokeAndWait( new Runnable() {
 135                     public void run() {} // Dummy implementation
 136                 });
 137         } catch(InterruptedException ie) {
 138             System.out.println("waitForIdle, non-fatal exception caught:");
 139             ie.printStackTrace();
 140         } catch(InvocationTargetException ite) {
 141             System.out.println("waitForIdle, non-fatal exception caught:");
 142             ite.printStackTrace();
 143         }
 144 
 145         // wait longer...
< prev index next >