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