1 /*
2 test
3 @bug 6271849
4 @summary Tests that component in modal excluded Window which parent is blocked responses to mouse clicks.
5 @author anton.tarasov@sun.com: area=awt.focus
6 @run applet ModalExcludedWindowClickTest.html
7 */
8
9 import java.applet.Applet;
10 import java.awt.*;
11 import java.awt.event.*;
12 import java.lang.reflect.*;
13
14 public class ModalExcludedWindowClickTest extends Applet {
15 Robot robot;
16 Frame frame = new Frame("Frame");
17 Window w = new Window(frame);
18 Dialog d = new Dialog ((Dialog)null, "NullParentDialog", true);
19 Button button = new Button("Button");
20 boolean actionPerformed = false;
21
96 } else {
97 robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
98 }
99 robot.mousePress(InputEvent.BUTTON1_MASK);
100 robot.mouseRelease(InputEvent.BUTTON1_MASK);
101 waitForIdle();
102 }
103 void waitTillShown(Component c) {
104 while (true) {
105 try {
106 Thread.sleep(100);
107 c.getLocationOnScreen();
108 break;
109 } catch (InterruptedException e) {
110 throw new RuntimeException(e);
111 } catch (IllegalComponentStateException e) {}
112 }
113 }
114 void waitForIdle() {
115 try {
116 Toolkit.getDefaultToolkit().sync();
117 sun.awt.SunToolkit.flushPendingEvents();
118 EventQueue.invokeAndWait( new Runnable() {
119 public void run() {} // Dummy implementation
120 });
121 } catch(InterruptedException ie) {
122 Sysout.println("waitForIdle, non-fatal exception caught:");
123 ie.printStackTrace();
124 } catch(InvocationTargetException ite) {
125 Sysout.println("waitForIdle, non-fatal exception caught:");
126 ite.printStackTrace();
127 }
128
129 // wait longer...
130 robot.delay(200);
131 }
132 }
133
134 /****************************************************
135 Standard Test Machinery
136 DO NOT modify anything below -- it's a standard
137 chunk of code whose purpose is to make user
|
1 /*
2 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 test
26 @bug 6271849
27 @summary Tests that component in modal excluded Window which parent is blocked responses to mouse clicks.
28 @author anton.tarasov@sun.com: area=awt.focus
29 @run applet ModalExcludedWindowClickTest.html
30 */
31
32 import java.applet.Applet;
33 import java.awt.*;
34 import java.awt.event.*;
35 import java.lang.reflect.*;
36
37 public class ModalExcludedWindowClickTest extends Applet {
38 Robot robot;
39 Frame frame = new Frame("Frame");
40 Window w = new Window(frame);
41 Dialog d = new Dialog ((Dialog)null, "NullParentDialog", true);
42 Button button = new Button("Button");
43 boolean actionPerformed = false;
44
119 } else {
120 robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
121 }
122 robot.mousePress(InputEvent.BUTTON1_MASK);
123 robot.mouseRelease(InputEvent.BUTTON1_MASK);
124 waitForIdle();
125 }
126 void waitTillShown(Component c) {
127 while (true) {
128 try {
129 Thread.sleep(100);
130 c.getLocationOnScreen();
131 break;
132 } catch (InterruptedException e) {
133 throw new RuntimeException(e);
134 } catch (IllegalComponentStateException e) {}
135 }
136 }
137 void waitForIdle() {
138 try {
139 robot.waitForIdle();
140 EventQueue.invokeAndWait( new Runnable() {
141 public void run() {} // Dummy implementation
142 });
143 } catch(InterruptedException ie) {
144 Sysout.println("waitForIdle, non-fatal exception caught:");
145 ie.printStackTrace();
146 } catch(InvocationTargetException ite) {
147 Sysout.println("waitForIdle, non-fatal exception caught:");
148 ite.printStackTrace();
149 }
150
151 // wait longer...
152 robot.delay(200);
153 }
154 }
155
156 /****************************************************
157 Standard Test Machinery
158 DO NOT modify anything below -- it's a standard
159 chunk of code whose purpose is to make user
|