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