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