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