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