Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Headless/HeadlessCheckboxMenuItem.java
41149 views
1
/*
2
* Copyright (c) 2007, 2014, 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 java.awt.*;
25
26
/*
27
* @test
28
* @summary Check that CheckboxMenuItem constructors throw HeadlessException
29
* in headless mode
30
* @run main/othervm -Djava.awt.headless=true HeadlessCheckboxMenuItem
31
*/
32
33
public class HeadlessCheckboxMenuItem {
34
35
public static void main(String args[]) {
36
CheckboxMenuItem c;
37
38
boolean exceptions = false;
39
try {
40
c = new CheckboxMenuItem();
41
} catch (HeadlessException e) {
42
exceptions = true;
43
}
44
if (!exceptions)
45
throw new RuntimeException("Constructor did not throw HeadlessException");
46
47
exceptions = false;
48
try {
49
c = new CheckboxMenuItem("Choices...");
50
} catch (HeadlessException e) {
51
exceptions = true;
52
}
53
if (!exceptions)
54
throw new RuntimeException("Constructor did not throw HeadlessException");
55
56
exceptions = false;
57
try {
58
c = new CheckboxMenuItem("Choices...", true);
59
} catch (HeadlessException e) {
60
exceptions = true;
61
}
62
if (!exceptions)
63
throw new RuntimeException("Constructor did not throw HeadlessException");
64
65
exceptions = false;
66
try {
67
c = new CheckboxMenuItem("Choices...", false);
68
} catch (HeadlessException e) {
69
exceptions = true;
70
}
71
if (!exceptions)
72
throw new RuntimeException("Constructor did not throw HeadlessException");
73
74
}
75
}
76
77