Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Frame/MaximizedToOppositeScreen/MaximizedToOppositeScreenBig.java
41153 views
1
/*
2
* Copyright (c) 2020, 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
import java.awt.Frame;
25
import java.awt.GraphicsDevice;
26
import java.awt.GraphicsEnvironment;
27
import java.awt.Rectangle;
28
import java.awt.Robot;
29
import java.awt.Toolkit;
30
31
/**
32
* @test
33
* @bug 8176359 8231564
34
* @key headful
35
* @requires (os.family == "windows" | os.family == "mac")
36
* @summary setMaximizedBounds() should work if set to the screen other than
37
* current screen of the Frame, the size of the frame is intentionally
38
* big
39
* @run main/othervm MaximizedToOppositeScreenBig
40
* @run main/othervm -Dsun.java2d.uiScale=1 MaximizedToOppositeScreenBig
41
* @run main/othervm -Dsun.java2d.uiScale=1.2 MaximizedToOppositeScreenBig
42
* @run main/othervm -Dsun.java2d.uiScale=1.25 MaximizedToOppositeScreenBig
43
* @run main/othervm -Dsun.java2d.uiScale=1.5 MaximizedToOppositeScreenBig
44
* @run main/othervm -Dsun.java2d.uiScale=1.75 MaximizedToOppositeScreenBig
45
* @run main/othervm -Dsun.java2d.uiScale=2 MaximizedToOppositeScreenBig
46
* @run main/othervm -Dsun.java2d.uiScale=2.25 MaximizedToOppositeScreenBig
47
*/
48
public final class MaximizedToOppositeScreenBig {
49
50
public static void main(String[] args) throws Exception {
51
//Supported platforms are Windows and OS X.
52
String os = System.getProperty("os.name").toLowerCase();
53
if (!os.contains("windows") && !os.contains("os x")) {
54
return;
55
}
56
57
if (!Toolkit.getDefaultToolkit().
58
isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {
59
return;
60
}
61
62
var ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
63
GraphicsDevice[] gds = ge.getScreenDevices();
64
Robot robot = new Robot();
65
for (GraphicsDevice gd1 : gds) {
66
Rectangle framAt = gd1.getDefaultConfiguration().getBounds();
67
framAt.grow(-200, -200);
68
for (GraphicsDevice gd2 : gds) {
69
Rectangle maxTo = gd2.getDefaultConfiguration().getBounds();
70
maxTo.grow(-150, -150);
71
Frame frame = new Frame(gd1.getDefaultConfiguration());
72
try {
73
frame.setBounds(framAt);
74
frame.setVisible(true);
75
robot.waitForIdle();
76
robot.delay(1000);
77
78
frame.setMaximizedBounds(maxTo);
79
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
80
robot.waitForIdle();
81
robot.delay(1000);
82
83
Rectangle actual = frame.getBounds();
84
if (!actual.equals(maxTo)) {
85
System.err.println("Actual: " + actual);
86
System.err.println("Expected: " + maxTo);
87
throw new RuntimeException("Wrong bounds");
88
}
89
} finally {
90
frame.dispose();
91
}
92
}
93
}
94
}
95
}
96
97
98