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