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