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 @key headful
27 @bug 4823903
28 @summary Tests actual focused window retaining.
29 @author Anton.Tarasov: area=awt.focus
30 @library ../../regtesthelpers
31 @build Util
32 @run main ActualFocusedWindowRetaining
33 */
34
35 import java.awt.*;
36 import java.awt.event.*;
37 import java.lang.reflect.*;
38 import java.applet.*;
39 import test.java.awt.regtesthelpers.Util;
40
41 public class ActualFocusedWindowRetaining extends Applet {
42 public static Frame frame = new Frame("Other Frame");
43 public static Frame owner = new Frame("Test Frame");
44 public static Button otherButton1 = new Button("Other Button 1");
45 public static Button otherButton2 = new Button("Other Button 2");
46 public static Button otherButton3 = new Button("Other Button 3");
47 public static Button testButton1 = new Button("Test Button 1");
48 public static Button testButton2 = new Button("Test Button 2");
49 public static Button testButton3 = new Button("Test Button 3");
50 public static Window window1 = new TestWindow(owner, otherButton2, testButton2, 800, 200);
51 public static Window window2 = new TestWindow(owner, otherButton3, testButton3, 800, 300);
52 public static int step;
53 public static Robot robot = Util.createRobot();
54
55 public static void main(String[] args) {
56 ActualFocusedWindowRetaining a = new ActualFocusedWindowRetaining();
57 a.init();
58 a.start();
59 }
60
61 public void start () {
62 Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
63 public void eventDispatched(AWTEvent e) {
64 Object src = e.getSource();
65 Class cls = src.getClass();
66
67 if (cls == TestWindow.class) {
68 System.out.println(e.paramString() + " on <" + (src == window1 ? "Window 1" : "Window 2") + ">");
69 } else if (cls == Frame.class) {
70 System.out.println(e.paramString() + " on <" + ((Frame)src).getTitle() + ">");
71 } else if (cls == Button.class) {
72 System.out.println(e.paramString() + " on <" + ((Button)src).getLabel() + ">");
73 } else {
74 System.out.println(e.paramString() + " on <Non-testing component>");
75 }
76 }
77 }, AWTEvent.WINDOW_EVENT_MASK | AWTEvent.WINDOW_FOCUS_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
78
79 setSize (500, 200);
80 setVisible(true);
81 validate();
82
83 frame.setSize(new Dimension(400, 100));
84 frame.setLocation(800, 400);
85 frame.setVisible(true);
86 frame.toFront();
87
88 owner.setLayout(new FlowLayout());
89 owner.add(testButton1);
90 owner.add(otherButton1);
91 owner.pack();
92 owner.setLocation(800, 100);
93 owner.setSize(new Dimension(400, 100));
94 owner.setVisible(true);
95 owner.toFront();
96 Util.waitTillShown(owner);
97
98 window1.setVisible(true);
99 window2.setVisible(true);
100 window1.toFront();
101 window2.toFront();
102 // Wait longer...
|
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 @key headful
27 @bug 4823903
28 @summary Tests actual focused window retaining.
29 @library ../../regtesthelpers
30 @build Util
31 @run main ActualFocusedWindowRetaining
32 */
33
34 import java.awt.*;
35 import java.awt.event.*;
36 import test.java.awt.regtesthelpers.Util;
37
38 public class ActualFocusedWindowRetaining {
39 public static Frame frame = new Frame("Other Frame");
40 public static Frame owner = new Frame("Test Frame");
41 public static Button otherButton1 = new Button("Other Button 1");
42 public static Button otherButton2 = new Button("Other Button 2");
43 public static Button otherButton3 = new Button("Other Button 3");
44 public static Button testButton1 = new Button("Test Button 1");
45 public static Button testButton2 = new Button("Test Button 2");
46 public static Button testButton3 = new Button("Test Button 3");
47 public static Window window1 = new TestWindow(owner, otherButton2, testButton2, 800, 200);
48 public static Window window2 = new TestWindow(owner, otherButton3, testButton3, 800, 300);
49 public static int step;
50 public static Robot robot = Util.createRobot();
51
52 public static void main(String[] args) {
53 ActualFocusedWindowRetaining a = new ActualFocusedWindowRetaining();
54 a.start();
55 }
56
57 public void start () {
58 Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
59 public void eventDispatched(AWTEvent e) {
60 Object src = e.getSource();
61 Class cls = src.getClass();
62
63 if (cls == TestWindow.class) {
64 System.out.println(e.paramString() + " on <" + (src == window1 ? "Window 1" : "Window 2") + ">");
65 } else if (cls == Frame.class) {
66 System.out.println(e.paramString() + " on <" + ((Frame)src).getTitle() + ">");
67 } else if (cls == Button.class) {
68 System.out.println(e.paramString() + " on <" + ((Button)src).getLabel() + ">");
69 } else {
70 System.out.println(e.paramString() + " on <Non-testing component>");
71 }
72 }
73 }, AWTEvent.WINDOW_EVENT_MASK | AWTEvent.WINDOW_FOCUS_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
74
75 frame.setSize(new Dimension(400, 100));
76 frame.setLocation(800, 400);
77 frame.setVisible(true);
78 frame.toFront();
79
80 owner.setLayout(new FlowLayout());
81 owner.add(testButton1);
82 owner.add(otherButton1);
83 owner.pack();
84 owner.setLocation(800, 100);
85 owner.setSize(new Dimension(400, 100));
86 owner.setVisible(true);
87 owner.toFront();
88 Util.waitTillShown(owner);
89
90 window1.setVisible(true);
91 window2.setVisible(true);
92 window1.toFront();
93 window2.toFront();
94 // Wait longer...
|