author | jdv |
Wed, 15 May 2019 10:10:53 +0530 | |
branch | metal-prototype-branch |
changeset 57357 | f3beca8f19fc |
parent 47216 | 71c04702a3d5 |
child 59191 | 1e8bbeb86204 |
permissions | -rw-r--r-- |
40993
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
1 |
/* |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
4 |
* |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
8 |
* |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
13 |
* accompanied this code). |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
14 |
* |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
18 |
* |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
21 |
* questions. |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
22 |
*/ |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
23 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
24 |
/* |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
25 |
* @test |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
26 |
* @key headful |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
27 |
* @bug 8050478 |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
28 |
* @summary Cursor not updating correctly after closing a modal dialog. |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
29 |
* The root cause of the issue was the lack of a mouse exit event |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
30 |
* during displaying of a modal dialog. |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
31 |
* @author Dmitry Markov |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
32 |
* @library ../../regtesthelpers |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
33 |
* @build Util |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
34 |
* @run main ModalDialogEnterExitEventsTest |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
35 |
*/ |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
36 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
37 |
import javax.swing.JButton; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
38 |
import javax.swing.JDialog; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
39 |
import javax.swing.JFrame; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
40 |
import javax.swing.SwingUtilities; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
41 |
import java.awt.FlowLayout; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
42 |
import java.awt.Frame; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
43 |
import java.awt.Robot; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
44 |
import java.awt.event.ActionEvent; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
45 |
import java.awt.event.ActionListener; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
46 |
import java.awt.event.MouseAdapter; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
47 |
import java.awt.event.MouseEvent; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
48 |
import java.util.concurrent.atomic.AtomicInteger; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
49 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
50 |
import test.java.awt.regtesthelpers.Util; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
51 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
52 |
public class ModalDialogEnterExitEventsTest { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
53 |
private static volatile AtomicInteger mouseEnterCount = new AtomicInteger(); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
54 |
private static volatile AtomicInteger mouseExitCount = new AtomicInteger(); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
55 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
56 |
private static JFrame frame; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
57 |
private static JButton openButton; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
58 |
private static JButton closeButton; |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
59 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
60 |
public static void main(String[] args) { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
61 |
Robot robot = Util.createRobot(); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
62 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
63 |
SwingUtilities.invokeLater(new Runnable() { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
64 |
@Override |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
65 |
public void run() { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
66 |
createAndShowGUI(); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
67 |
} |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
68 |
}); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
69 |
Util.waitForIdle(robot); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
70 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
71 |
Util.clickOnComp(frame, robot, 500); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
72 |
Util.waitForIdle(robot); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
73 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
74 |
mouseEnterCount.set(0); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
75 |
mouseExitCount.set(0); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
76 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
77 |
Util.clickOnComp(openButton, robot, 500); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
78 |
Util.waitForIdle(robot); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
79 |
if (mouseExitCount.get() != 1) { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
80 |
throw new RuntimeException("Test FAILED. Wrong number of MouseExited events = " + mouseExitCount.get()); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
81 |
} |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
82 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
83 |
Util.clickOnComp(closeButton, robot, 500); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
84 |
Util.waitForIdle(robot); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
85 |
if (mouseEnterCount.get() != 1) { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
86 |
throw new RuntimeException("Test FAILED. Wrong number of MouseEntered events = "+ mouseEnterCount.get()); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
87 |
} |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
88 |
} |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
89 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
90 |
private static void createAndShowGUI() { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
91 |
frame = new JFrame("ModalDialogEnterExitEventsTest"); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
92 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
93 |
frame.setLayout(new FlowLayout()); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
94 |
frame.addMouseListener(new MouseAdapter() { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
95 |
@Override |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
96 |
public void mouseExited(MouseEvent e) { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
97 |
mouseExitCount.getAndIncrement(); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
98 |
} |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
99 |
|
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
100 |
@Override |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
101 |
public void mouseEntered(MouseEvent e) { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
102 |
mouseEnterCount.getAndIncrement(); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
103 |
} |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
104 |
}); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
105 |
openButton = new JButton("Open Dialog"); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
106 |
openButton.addActionListener(new ActionListener() { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
107 |
@Override |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
108 |
public void actionPerformed(ActionEvent e) { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
109 |
JDialog dialog = new JDialog(frame, "Modal Dialog", true); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
110 |
dialog.setLayout(new FlowLayout()); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
111 |
closeButton = new JButton("Close"); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
112 |
closeButton.addActionListener(new ActionListener() { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
113 |
@Override |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
114 |
public void actionPerformed(ActionEvent e) { |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
115 |
dialog.dispose(); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
116 |
} |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
117 |
}); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
118 |
dialog.add(closeButton); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
119 |
dialog.setSize(200, 200); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
120 |
dialog.setLocationRelativeTo(null); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
121 |
dialog.setVisible(true); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
122 |
} |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
123 |
}); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
124 |
frame.add(openButton); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
125 |
frame.setExtendedState(Frame.MAXIMIZED_BOTH); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
126 |
frame.setVisible(true); |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
127 |
} |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
128 |
} |
a24dc7d0dd28
8050478: [macosx] Cursor not updating correctly after closing a modal dialog
dmarkov
parents:
diff
changeset
|
129 |