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