Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/Headless/HeadlessJOptionPane.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 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.getGraphicsConfiguration();
116
op.getTreeLock();
117
op.getToolkit();
118
op.isValid();
119
op.isDisplayable();
120
op.isVisible();
121
op.isShowing();
122
op.isEnabled();
123
op.enable(false);
124
op.enable(true);
125
op.enableInputMethods(false);
126
op.enableInputMethods(true);
127
op.show();
128
op.show(false);
129
op.show(true);
130
op.hide();
131
op.getForeground();
132
op.isForegroundSet();
133
op.getBackground();
134
op.isBackgroundSet();
135
op.getFont();
136
op.isFontSet();
137
Container c = new Container();
138
c.add(op);
139
op.getLocale();
140
for (Locale locale : Locale.getAvailableLocales())
141
op.setLocale(locale);
142
143
op.getColorModel();
144
op.getLocation();
145
146
boolean exceptions = false;
147
try {
148
op.getLocationOnScreen();
149
} catch (IllegalComponentStateException e) {
150
exceptions = true;
151
}
152
if (!exceptions)
153
throw new RuntimeException("IllegalComponentStateException did not occur when expected");
154
155
op.location();
156
op.setLocation(1, 2);
157
op.move(1, 2);
158
op.setLocation(new Point(1, 2));
159
op.getSize();
160
op.size();
161
op.setSize(1, 32);
162
op.resize(1, 32);
163
op.setSize(new Dimension(1, 32));
164
op.resize(new Dimension(1, 32));
165
op.getBounds();
166
op.bounds();
167
op.setBounds(10, 10, 10, 10);
168
op.setBounds(new Rectangle(10, 10, 10, 10));
169
op.isLightweight();
170
op.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
171
op.getCursor();
172
op.isCursorSet();
173
op.inside(1, 2);
174
op.contains(new Point(1, 2));
175
op.isFocusable();
176
op.setFocusable(true);
177
op.setFocusable(false);
178
op.transferFocus();
179
op.getFocusCycleRootAncestor();
180
op.nextFocus();
181
op.transferFocusUpCycle();
182
op.hasFocus();
183
op.isFocusOwner();
184
op.toString();
185
op.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
186
op.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
187
op.setComponentOrientation(ComponentOrientation.UNKNOWN);
188
op.getComponentOrientation();
189
}
190
}
191
192