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