74 } 75 return true; 76 } 77 }); 78 JTextField t2 = new JTextField(); 79 80 81 frame.getContentPane().add(t1, BorderLayout.NORTH); 82 frame.getContentPane().add(t2, BorderLayout.SOUTH); 83 frame.setSize(200, 200); 84 frame.setVisible(true); 85 86 Robot r = null; 87 try { 88 r = new Robot(); 89 } catch (AWTException e) { 90 EndlessLoopTest.fail(e); 91 } 92 93 try { 94 sun.awt.SunToolkit tk = (sun.awt.SunToolkit) Toolkit.getDefaultToolkit(); 95 tk.realSync(); 96 97 mouseClickOnComp(r, t1); 98 tk.realSync(); 99 100 if (!t1.isFocusOwner()) { 101 throw new RuntimeException("t1 is not a focus owner"); 102 } 103 n_iv_calls = 0; 104 r.keyPress(KeyEvent.VK_TAB); 105 r.delay(10); 106 r.keyRelease(KeyEvent.VK_TAB); 107 tk.realSync(); 108 109 mouseClickOnComp(r, button); 110 tk.realSync(); 111 } catch (Exception e) { 112 EndlessLoopTest.fail(e); 113 } 114 115 if (n_iv_calls != 1) { 116 EndlessLoopTest.fail(new RuntimeException("InputVerifier was called " + n_iv_calls + " times")); 117 } 118 119 EndlessLoopTest.pass(); 120 121 }//End init() 122 123 124 static void mouseClickOnComp(Robot r, Component comp) { 125 Point loc = comp.getLocationOnScreen(); 126 loc.x += comp.getWidth() / 2; 127 loc.y += comp.getHeight() / 2; 128 r.mouseMove(loc.x, loc.y); 129 r.delay(10); 130 r.mousePress(InputEvent.BUTTON1_MASK); | 74 } 75 return true; 76 } 77 }); 78 JTextField t2 = new JTextField(); 79 80 81 frame.getContentPane().add(t1, BorderLayout.NORTH); 82 frame.getContentPane().add(t2, BorderLayout.SOUTH); 83 frame.setSize(200, 200); 84 frame.setVisible(true); 85 86 Robot r = null; 87 try { 88 r = new Robot(); 89 } catch (AWTException e) { 90 EndlessLoopTest.fail(e); 91 } 92 93 try { 94 r.waitForIdle(); 95 96 mouseClickOnComp(r, t1); 97 r.waitForIdle(); 98 99 if (!t1.isFocusOwner()) { 100 throw new RuntimeException("t1 is not a focus owner"); 101 } 102 n_iv_calls = 0; 103 r.keyPress(KeyEvent.VK_TAB); 104 r.delay(10); 105 r.keyRelease(KeyEvent.VK_TAB); 106 r.waitForIdle(); 107 108 mouseClickOnComp(r, button); 109 r.waitForIdle(); 110 } catch (Exception e) { 111 EndlessLoopTest.fail(e); 112 } 113 114 if (n_iv_calls != 1) { 115 EndlessLoopTest.fail(new RuntimeException("InputVerifier was called " + n_iv_calls + " times")); 116 } 117 118 EndlessLoopTest.pass(); 119 120 }//End init() 121 122 123 static void mouseClickOnComp(Robot r, Component comp) { 124 Point loc = comp.getLocationOnScreen(); 125 loc.x += comp.getWidth() / 2; 126 loc.y += comp.getHeight() / 2; 127 r.mouseMove(loc.x, loc.y); 128 r.delay(10); 129 r.mousePress(InputEvent.BUTTON1_MASK); |