author | jdv |
Wed, 15 May 2019 10:10:53 +0530 | |
branch | metal-prototype-branch |
changeset 57357 | f3beca8f19fc |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
12535
diff
changeset
|
2 |
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
4 |
* |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
8 |
* |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
13 |
* accompanied this code). |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
14 |
* |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
18 |
* |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
21 |
* questions. |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
22 |
*/ |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
23 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
24 |
/* |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
25 |
* @test |
40128
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
28087
diff
changeset
|
26 |
* @key headful |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
27 |
* @bug 7154048 |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
28 |
* @summary Window created under a mouse does not receive mouse enter event. |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
29 |
* Mouse Entered/Exited events should be generated during dragging the window |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
30 |
* out of the frame and to the frame. |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
31 |
* @library ../../regtesthelpers |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
32 |
* @build Util |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
33 |
* @author alexandr.scherbatiy area=awt.event |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
34 |
* @run main DragWindowOutOfFrameTest |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
35 |
*/ |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
36 |
import java.awt.*; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
37 |
import java.awt.event.*; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
38 |
import javax.swing.*; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
39 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
40 |
import java.util.concurrent.*; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
41 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
42 |
import test.java.awt.regtesthelpers.Util; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
43 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
44 |
public class DragWindowOutOfFrameTest { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
45 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
46 |
private static volatile int dragWindowMouseEnteredCount = 0; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
47 |
private static volatile int dragWindowMouseExitedCount = 0; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
48 |
private static volatile int dragWindowMouseReleasedCount = 0; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
49 |
private static volatile int buttonMouseEnteredCount = 0; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
50 |
private static volatile int buttonMouseExitedCount = 0; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
51 |
private static volatile int labelMouseEnteredCount = 0; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
52 |
private static volatile int labelMouseExitedCount = 0; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
53 |
private static volatile int labelMouseReleasedCount = 0; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
54 |
private static MyDragWindow dragWindow; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
55 |
private static JLabel label; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
56 |
private static JButton button; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
57 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
58 |
public static void main(String[] args) throws Exception { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
59 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
60 |
Robot robot = new Robot(); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
61 |
robot.setAutoDelay(50); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
62 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
63 |
SwingUtilities.invokeAndWait(new Runnable() { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
64 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
65 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
66 |
public void run() { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
67 |
createAndShowGUI(); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
68 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
69 |
}); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
70 |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
23010
diff
changeset
|
71 |
robot.waitForIdle(); |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
72 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
73 |
Point pointToClick = Util.invokeOnEDT(new Callable<Point>() { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
74 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
75 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
76 |
public Point call() throws Exception { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
77 |
return getCenterPoint(label); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
78 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
79 |
}); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
80 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
81 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
82 |
robot.mouseMove(pointToClick.x, pointToClick.y); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
83 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
23010
diff
changeset
|
84 |
robot.waitForIdle(); |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
85 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
86 |
if (dragWindowMouseEnteredCount != 1 && dragWindowMouseExitedCount != 0) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
87 |
throw new RuntimeException( |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
88 |
"Wrong number mouse Entered/Exited events on Drag Window!"); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
89 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
90 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
91 |
Point pointToDrag = Util.invokeOnEDT(new Callable<Point>() { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
92 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
93 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
94 |
public Point call() throws Exception { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
95 |
label.addMouseListener(new LabelMouseListener()); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
96 |
button.addMouseListener(new ButtonMouseListener()); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
97 |
return getCenterPoint(button); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
98 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
99 |
}); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
100 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
101 |
robot.mouseMove(450, pointToClick.y); |
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
23010
diff
changeset
|
102 |
robot.waitForIdle(); |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
103 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
104 |
if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
105 |
throw new RuntimeException( |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
106 |
"Wrong number Mouse Entered/Exited events on label!"); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
107 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
108 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
109 |
robot.mouseMove(450, pointToDrag.y); |
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
23010
diff
changeset
|
110 |
robot.waitForIdle(); |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
111 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
112 |
if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
113 |
throw new RuntimeException( |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
114 |
"Wrong number Mouse Entered/Exited events on label!"); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
115 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
116 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
117 |
if (buttonMouseEnteredCount != 0 && buttonMouseExitedCount != 0) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
118 |
throw new RuntimeException( |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
119 |
"Wrong number Mouse Entered/Exited events on button!"); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
120 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
121 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
122 |
robot.mouseMove(pointToDrag.y, pointToDrag.y); |
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
23010
diff
changeset
|
123 |
robot.waitForIdle(); |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
124 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
125 |
if (buttonMouseEnteredCount != 1 && buttonMouseExitedCount != 0) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
126 |
throw new RuntimeException( |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
127 |
"Wrong number Mouse Entered/Exited events on button!"); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
128 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
129 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
130 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
23010
diff
changeset
|
131 |
robot.waitForIdle(); |
12535
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
132 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
133 |
if (labelMouseReleasedCount != 1) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
134 |
throw new RuntimeException("No MouseReleased event on label!"); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
135 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
136 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
137 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
138 |
private static Point getCenterPoint(Component comp) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
139 |
Point p = comp.getLocationOnScreen(); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
140 |
Rectangle rect = comp.getBounds(); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
141 |
return new Point(p.x + rect.width / 2, p.y + rect.height / 2); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
142 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
143 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
144 |
private static void createAndShowGUI() { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
145 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
146 |
JFrame frame = new JFrame("Main Frame"); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
147 |
frame.setLocation(100, 100); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
148 |
frame.setSize(300, 200); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
149 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
150 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
151 |
label = new JLabel("Label"); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
152 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
153 |
DragWindowCreationMouseListener listener = new DragWindowCreationMouseListener(frame); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
154 |
label.addMouseListener(listener); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
155 |
label.addMouseMotionListener(listener); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
156 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
157 |
button = new JButton("Button"); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
158 |
Panel panel = new Panel(new BorderLayout()); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
159 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
160 |
panel.add(label, BorderLayout.NORTH); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
161 |
panel.add(button, BorderLayout.CENTER); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
162 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
163 |
frame.getContentPane().add(panel); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
164 |
frame.setVisible(true); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
165 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
166 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
167 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
168 |
private static Point getAbsoluteLocation(MouseEvent e) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
169 |
return new Point(e.getXOnScreen(), e.getYOnScreen()); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
170 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
171 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
172 |
static class MyDragWindow extends Window { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
173 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
174 |
public MyDragWindow(Window parent, Point location) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
175 |
super(parent); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
176 |
setSize(500, 300); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
177 |
setVisible(true); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
178 |
JPanel panel = new JPanel(); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
179 |
add(panel); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
180 |
setLocation(location.x - 250, location.y - 150); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
181 |
addMouseListener(new DragWindowMouseListener()); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
182 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
183 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
184 |
void dragTo(Point point) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
185 |
setLocation(point.x - 250, point.y - 150); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
186 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
187 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
188 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
189 |
static class DragWindowCreationMouseListener extends MouseAdapter { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
190 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
191 |
Point origin; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
192 |
Window parent; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
193 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
194 |
public DragWindowCreationMouseListener(Window parent) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
195 |
this.parent = parent; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
196 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
197 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
198 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
199 |
public void mousePressed(MouseEvent e) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
200 |
if (dragWindow == null) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
201 |
dragWindow = new MyDragWindow(parent, getAbsoluteLocation(e)); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
202 |
} else { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
203 |
dragWindow.setVisible(true); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
204 |
dragWindow.dragTo(getAbsoluteLocation(e)); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
205 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
206 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
207 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
208 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
209 |
public void mouseReleased(MouseEvent e) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
210 |
labelMouseReleasedCount++; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
211 |
if (dragWindow != null) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
212 |
dragWindow.setVisible(false); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
213 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
214 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
215 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
216 |
public void mouseDragged(MouseEvent e) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
217 |
if (dragWindow != null) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
218 |
dragWindow.dragTo(getAbsoluteLocation(e)); |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
219 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
220 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
221 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
222 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
223 |
static class DragWindowMouseListener extends MouseAdapter { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
224 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
225 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
226 |
public void mouseEntered(MouseEvent e) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
227 |
dragWindowMouseEnteredCount++; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
228 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
229 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
230 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
231 |
public void mouseExited(MouseEvent e) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
232 |
dragWindowMouseExitedCount++; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
233 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
234 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
235 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
236 |
public void mouseReleased(MouseEvent e) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
237 |
dragWindowMouseReleasedCount++; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
238 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
239 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
240 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
241 |
static class LabelMouseListener extends MouseAdapter { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
242 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
243 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
244 |
public void mouseEntered(MouseEvent e) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
245 |
labelMouseEnteredCount++; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
246 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
247 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
248 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
249 |
public void mouseExited(MouseEvent e) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
250 |
labelMouseExitedCount++; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
251 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
252 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
253 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
254 |
static class ButtonMouseListener extends MouseAdapter { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
255 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
256 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
257 |
public void mouseEntered(MouseEvent e) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
258 |
buttonMouseEnteredCount++; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
259 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
260 |
|
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
261 |
@Override |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
262 |
public void mouseExited(MouseEvent e) { |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
263 |
buttonMouseExitedCount++; |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
264 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
265 |
} |
6d2ee83614e8
7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents:
diff
changeset
|
266 |
} |