Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Modal/SupportedTest/SupportedTest.java
41153 views
1
/*
2
* Copyright (c) 2007, 2016, 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
/*
25
@test
26
@key headful
27
@bug 6520635
28
@summary Test that modality and modal exclusion types are handled
29
correctly according Toolkit.isModalityTypeSupported() and
30
Toolkit.isModalExclusionTypeSupported() methods
31
@author artem.ananiev: area=awt.modal
32
@run main SupportedTest
33
*/
34
35
import java.awt.*;
36
37
public class SupportedTest
38
{
39
public static void main(String[] args)
40
{
41
boolean passed = true;
42
Toolkit tk = Toolkit.getDefaultToolkit();
43
44
// check for modality types
45
46
Frame f = new Frame("F");
47
for (Dialog.ModalityType mt : Dialog.ModalityType.values())
48
{
49
if (!tk.isModalityTypeSupported(mt))
50
{
51
Dialog d = new Dialog(f, "D", mt);
52
if (!d.getModalityType().equals(Dialog.ModalityType.MODELESS))
53
{
54
System.err.println("Error: modality type " + mt + " is not supported\n" +
55
"but a dialog with this modality type can be created");
56
passed = false;
57
}
58
}
59
}
60
61
// check for modal exclusion types
62
for (Dialog.ModalExclusionType et : Dialog.ModalExclusionType.values())
63
{
64
if (!tk.isModalExclusionTypeSupported(et))
65
{
66
Frame g = new Frame("G");
67
g.setModalExclusionType(et);
68
if (!g.getModalExclusionType().equals(Dialog.ModalExclusionType.NO_EXCLUDE))
69
{
70
System.err.println("Error: modal exclusion type " + et + "is not supported\n" +
71
"but a window with this modal exclusion type can be created");
72
passed = false;
73
}
74
}
75
}
76
77
if (!passed)
78
{
79
throw new RuntimeException("Test FAILED: some of modality types and/or modal exclusion types are handled incorrectly");
80
}
81
}
82
}
83
84