Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Modal/ToFront/FrameToFrontModelessTest.java
41153 views
1
/*
2
* Copyright (c) 2007, 2014, 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
import java.awt.*;
26
27
28
public class FrameToFrontModelessTest {
29
30
private volatile TestDialog dialog;
31
private volatile TestFrame leftFrame, rightFrame;
32
33
private static final int delay = 500;
34
private final ExtendedRobot robot;
35
36
private boolean isModeless;
37
38
public FrameToFrontModelessTest(boolean modeless) throws Exception {
39
isModeless = modeless;
40
robot = new ExtendedRobot();
41
EventQueue.invokeLater(this::createGUI);
42
}
43
44
private void createGUI() {
45
46
leftFrame = new TestFrame();
47
leftFrame.setSize(200, 100);
48
leftFrame.setLocation(50, 50);
49
leftFrame.setVisible(true);
50
51
dialog = new TestDialog(leftFrame);
52
if (isModeless) { dialog.setModalityType(Dialog.ModalityType.MODELESS); }
53
dialog.setSize(200, 100);
54
dialog.setLocation(150, 50);
55
dialog.setVisible(true);
56
57
rightFrame = new TestFrame();
58
rightFrame.setSize(200, 100);
59
rightFrame.setLocation(250, 50);
60
rightFrame.setVisible(true);
61
}
62
63
64
public void doTest() throws Exception {
65
66
try {
67
68
robot.waitForIdle(delay);
69
70
EventQueue.invokeAndWait(() -> { leftFrame.toFront(); });
71
robot.waitForIdle(delay);
72
73
leftFrame.clickDummyButton(
74
robot, 7, false, "Calling toFront method on the parent " +
75
"left frame brought it to the top of the child dialog");
76
robot.waitForIdle(delay);
77
78
// show the right frame appear on top of the dialog
79
rightFrame.clickDummyButton(robot);
80
robot.waitForIdle(delay);
81
82
String msg = "The " + (isModeless ? "modeless" : "non-modal") +
83
" dialog still on top of the right frame" +
84
" even after a button on the frame is clicked";
85
dialog.clickDummyButton(robot, 7, false, msg);
86
87
} finally {
88
EventQueue.invokeAndWait(this::closeAll);
89
}
90
}
91
92
private void closeAll() {
93
if (dialog != null) { dialog.dispose(); }
94
if (leftFrame != null) { leftFrame.dispose(); }
95
if (rightFrame != null) { rightFrame.dispose(); }
96
}
97
}
98
99
100