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