Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/jdk/java/awt/Frame/SetMinimumSizeTest/SetMinimumSizeTest1.java
66646 views
1
/*
2
* Copyright (c) 2022, 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
* @test
26
* @key headful
27
* @summary Verify that increase in Frame's minimumSize gets reflected in the subsequent getSize call
28
* @run main SetMinimumSizeTest1
29
*/
30
31
import java.awt.Button;
32
import java.awt.Dimension;
33
import java.awt.EventQueue;
34
import java.awt.Frame;
35
import java.awt.Robot;
36
37
public class SetMinimumSizeTest1 {
38
39
private static Frame frame;
40
private static volatile Dimension dimension;
41
private static volatile Dimension actualDimension;
42
43
public static void createGUI() {
44
frame = new Frame();
45
frame.add(new Button("Button"));
46
frame.setSize(140, 140);
47
frame.setLocationRelativeTo(null);
48
frame.setVisible(true);
49
}
50
51
public static void doTest() throws Exception {
52
try {
53
EventQueue.invokeAndWait(() -> createGUI());
54
55
Robot robot = new Robot();
56
robot.setAutoDelay(100);
57
robot.waitForIdle();
58
59
EventQueue.invokeAndWait(() -> {
60
dimension = frame.getSize();
61
dimension.width += 20;
62
dimension.height += 20;
63
frame.setMinimumSize(dimension);
64
frame.invalidate();
65
frame.validate();
66
});
67
68
robot.waitForIdle();
69
70
EventQueue.invokeAndWait(() -> {
71
actualDimension = frame.getSize();
72
});
73
74
if (!actualDimension.equals(dimension)) {
75
throw new RuntimeException("Test Failed\n"
76
+ "expected dimension:(" + dimension.width + "," + dimension.height +")\n"
77
+ "actual dimension:(" + actualDimension.width + "," + actualDimension.height + ")");
78
}
79
} finally {
80
EventQueue.invokeAndWait(() -> frame.dispose());
81
}
82
}
83
84
public static void main(String[] args) throws Exception {
85
doTest();
86
}
87
}
88
89
90