< 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         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 


  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.mouseRelease(InputEvent.BUTTON1_MASK);
 119         waitForIdle();
 120     }
 121     void waitTillShown(Component c) {
 122         while (true) {
 123             try {
 124                 Thread.sleep(100);
 125                 Point p = c.getLocationOnScreen();
 126                 if (p != null)
 127                     break;
 128             } catch (InterruptedException e) {
 129                 throw new RuntimeException(e);
 130             } catch (IllegalComponentStateException e) {}
 131         }
 132     }
 133     void waitForIdle() {
 134         try {
 135             robot.waitForIdle();
 136             EventQueue.invokeAndWait( new Runnable() {
 137                     public void run() {} // Dummy implementation
 138                 });
 139         } catch(InterruptedException ie) {
 140             System.out.println("waitForIdle, non-fatal exception caught:");
 141             ie.printStackTrace();
 142         } catch(InvocationTargetException ite) {
 143             System.out.println("waitForIdle, non-fatal exception caught:");
 144             ite.printStackTrace();
 145         }
 146 
< prev index next >