Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Component/Headless/HeadlessPanel.java
47311 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
import java.awt.*;
25
import java.util.Locale;
26
27
/*
28
* @test
29
* @summary Check that Panel constructors and methods do not throw unexpected
30
* exceptions in headless mode
31
* @run main/othervm -Djava.awt.headless=true HeadlessPanel
32
*/
33
34
public class HeadlessPanel {
35
public static void main(String args[]) {
36
Panel p;
37
p = new Panel();
38
p = new Panel(new FlowLayout());
39
p.getAccessibleContext();
40
Component c1 = p.add(new Component(){});
41
Component c2 = p.add(new Component(){});
42
Component c3 = p.add(new Component(){});
43
p.getComponentCount();
44
p.countComponents();
45
p.getComponent(1);
46
p.getComponent(2);
47
Component[] cs = p.getComponents();
48
Insets ins = p.getInsets();
49
ins = p.insets();
50
p.remove(0);
51
p.remove((Component) c2);
52
p.removeAll();
53
54
p.add(c1);
55
p.add(c2);
56
p.add(c3);
57
p.getLayout();
58
p.setLayout(new FlowLayout());
59
p.doLayout();
60
p.layout();
61
p.invalidate();
62
p.validate();
63
64
p.getPreferredSize();
65
p.preferredSize();
66
p.getMinimumSize();
67
p.minimumSize();
68
p.getMaximumSize();
69
p.getAlignmentX();
70
p.getAlignmentY();
71
p.getComponentAt(1, 2);
72
p.locate(1, 2);
73
p.getComponentAt(new Point(1, 2));
74
p.isFocusCycleRoot(new Container());
75
p.transferFocusBackward();
76
p.setName("goober");
77
p.getName();
78
p.getParent();
79
p.getPeer();
80
p.getGraphicsConfiguration();
81
p.getTreeLock();
82
p.getToolkit();
83
p.isValid();
84
p.isDisplayable();
85
p.isVisible();
86
p.isShowing();
87
p.isEnabled();
88
p.setEnabled(false);
89
p.setEnabled(true);
90
p.enable();
91
p.enable(false);
92
p.enable(true);
93
p.disable();
94
p.isDoubleBuffered();
95
p.enableInputMethods(false);
96
p.enableInputMethods(true);
97
p.setVisible(false);
98
p.setVisible(true);
99
p.show();
100
p.show(false);
101
p.show(true);
102
p.hide();
103
p.getForeground();
104
p.setForeground(Color.red);
105
p.isForegroundSet();
106
p.getBackground();
107
p.setBackground(Color.red);
108
p.isBackgroundSet();
109
p.getFont();
110
p.isFontSet();
111
p.getColorModel();
112
p.getLocation();
113
p.location();
114
p.setLocation(1, 2);
115
p.move(1, 2);
116
p.setLocation(new Point(1, 2));
117
p.getSize();
118
p.size();
119
p.setSize(1, 32);
120
p.resize(1, 32);
121
p.setSize(new Dimension(1, 32));
122
p.resize(new Dimension(1, 32));
123
p.getBounds();
124
p.bounds();
125
p.setBounds(10, 10, 10, 10);
126
p.reshape(10, 10, 10, 10);
127
p.setBounds(new Rectangle(10, 10, 10, 10));
128
p.getX();
129
p.getY();
130
p.getWidth();
131
p.getHeight();
132
p.getBounds(new Rectangle(1, 1, 1, 1));
133
p.getSize(new Dimension(1, 2));
134
p.getLocation(new Point(1, 2));
135
p.isOpaque();
136
p.isLightweight();
137
p.getGraphics();
138
139
140
for (String font : Toolkit.getDefaultToolkit().getFontList()) {
141
for (int j = 8; j < 17; j++) {
142
Font f1 = new Font(font, Font.PLAIN, j);
143
Font f2 = new Font(font, Font.BOLD, j);
144
Font f3 = new Font(font, Font.ITALIC, j);
145
Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j);
146
147
p.setFont(f1);
148
p.setFont(f2);
149
p.setFont(f3);
150
p.setFont(f4);
151
}
152
}
153
154
boolean exceptions = false;
155
try {
156
Container c = new Container();
157
p = new Panel();
158
c.add(p);
159
p.getLocale();
160
} catch (IllegalComponentStateException e) {
161
exceptions = true;
162
}
163
if (!exceptions)
164
throw new RuntimeException("IllegalComponentStateException did not occur when expected");
165
166
for (Locale locale : Locale.getAvailableLocales())
167
p.setLocale(locale);
168
169
exceptions = false;
170
try {
171
p.getLocationOnScreen();
172
} catch (IllegalComponentStateException e) {
173
exceptions = true;
174
}
175
if (!exceptions)
176
throw new RuntimeException("IllegalComponentStateException did not occur when expected");
177
178
for (String font : Toolkit.getDefaultToolkit().getFontList()) {
179
for (int j = 8; j
180
< 17; j++) {
181
Font f1 = new Font(font, Font.PLAIN, j);
182
Font f2 = new Font(font, Font.BOLD, j);
183
Font f3 = new Font(font, Font.ITALIC, j);
184
Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j);
185
186
p.getFontMetrics(f1);
187
p.getFontMetrics(f2);
188
p.getFontMetrics(f3);
189
p.getFontMetrics(f4);
190
}
191
}
192
193
Cursor c = new Cursor(Cursor.CROSSHAIR_CURSOR);
194
p.setCursor(c);
195
p.getCursor();
196
p.isCursorSet();
197
p.contains(1, 2);
198
p.inside(1, 2);
199
p.contains(new Point(1, 2));
200
p.isFocusTraversable();
201
p.isFocusable();
202
p.setFocusable(true);
203
p.setFocusable(false);
204
p.requestFocus();
205
p.requestFocusInWindow();
206
p.transferFocus();
207
p.getFocusCycleRootAncestor();
208
p.nextFocus();
209
p.transferFocusUpCycle();
210
p.hasFocus();
211
p.isFocusOwner();
212
p.toString();
213
p.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
214
p.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
215
p.setComponentOrientation(ComponentOrientation.UNKNOWN);
216
p.getComponentOrientation();
217
}
218
}
219
220