Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Choice/ChoiceFromMaximizedFrame/ChoiceFromMaximizedFrame.java
41152 views
1
/*
2
* Copyright (c) 2019, 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
* @bug 8234386
28
* @requires (os.family == "mac")
29
* @summary [macos] NPE was thrown at expanding Choice from maximized frame
30
* @run main ChoiceFromMaximizedFrame
31
*/
32
33
import java.awt.BorderLayout;
34
import java.awt.Canvas;
35
import java.awt.Choice;
36
import java.awt.Frame;
37
import java.awt.GraphicsConfiguration;
38
import java.awt.GraphicsEnvironment;
39
import java.awt.Insets;
40
import java.awt.Panel;
41
import java.awt.Rectangle;
42
import java.awt.Robot;
43
import java.awt.Toolkit;
44
import java.awt.event.KeyEvent;
45
46
public class ChoiceFromMaximizedFrame
47
{
48
static public void main(String args[]) throws Exception
49
{
50
Frame f = new Frame("ChoiceTest");
51
try {
52
Panel p =new Panel(new BorderLayout());
53
Choice choice = new Choice();
54
choice.addItem("aaa");
55
choice.addItem("bbb");
56
p.add("North",choice);
57
p.add("Center",new Canvas());
58
f.add(p);
59
60
GraphicsConfiguration gc = GraphicsEnvironment
61
.getLocalGraphicsEnvironment()
62
.getDefaultScreenDevice().getDefaultConfiguration();
63
Rectangle bounds = gc.getBounds();
64
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
65
int x = bounds.x + insets.left;
66
int y = bounds.y + insets.top;
67
int width = bounds.width - insets.left - insets.right;
68
int height = bounds.height - insets.top - insets.bottom;
69
Rectangle rect = new Rectangle(x, y, width, height);
70
f.pack();
71
f.setBounds(rect);
72
f.setVisible(true);
73
74
Robot robot = new Robot();
75
robot.waitForIdle();
76
robot.keyPress(KeyEvent.VK_SPACE);
77
robot.keyRelease(KeyEvent.VK_SPACE);
78
robot.delay(1000);
79
} finally {
80
f.dispose();
81
}
82
}
83
}
84
85