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