Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JFileChooser/8080628/bug8080628.java
41153 views
1
/*
2
* Copyright (c) 2015, 2018, 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.util.Locale;
25
import javax.swing.SwingUtilities;
26
import javax.swing.UIManager;
27
import javax.swing.UIManager.LookAndFeelInfo;
28
import javax.swing.UnsupportedLookAndFeelException;
29
30
import sun.swing.SwingUtilities2;
31
32
/*
33
* @test
34
* @bug 8080628
35
* @summary No mnemonics on Open and Save buttons in JFileChooser.
36
* @author Alexey Ivanov
37
* @modules java.desktop/sun.swing
38
* @run main bug8080628
39
*/
40
public class bug8080628 {
41
public static final String[] MNEMONIC_KEYS = new String[] {
42
"FileChooser.saveButtonMnemonic",
43
"FileChooser.openButtonMnemonic",
44
"FileChooser.cancelButtonMnemonic",
45
"FileChooser.directoryOpenButtonMnemonic"
46
};
47
48
public static final Locale[] LOCALES = new Locale[] {
49
new Locale("en"),
50
new Locale("de"),
51
new Locale("es"),
52
new Locale("fr"),
53
new Locale("it"),
54
new Locale("ja"),
55
new Locale("ko"),
56
new Locale("pt", "BR"),
57
new Locale("sv"),
58
new Locale("zh", "CN"),
59
new Locale("zh", "TW")
60
};
61
62
private static volatile Exception exception;
63
64
public static void main(String[] args) throws Exception {
65
SwingUtilities.invokeAndWait(new Runnable() {
66
@Override
67
public void run() {
68
runTest();
69
}
70
});
71
72
if (exception != null) {
73
throw exception;
74
}
75
}
76
77
private static void runTest() {
78
try {
79
LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
80
for (LookAndFeelInfo info : lafInfo) {
81
try {
82
UIManager.setLookAndFeel(info.getClassName());
83
} catch (final UnsupportedLookAndFeelException ignored) {
84
continue;
85
}
86
87
for (Locale locale : LOCALES) {
88
for (String key : MNEMONIC_KEYS) {
89
int mnemonic = SwingUtilities2.getUIDefaultsInt(key, locale);
90
if (mnemonic != 0) {
91
throw new RuntimeException("No mnemonic expected (" + mnemonic + ") " +
92
"for '" + key + "' " +
93
"in locale '" + locale + "' " +
94
"in Look-and-Feel '"
95
+ UIManager.getLookAndFeel().getClass().getName() + "'");
96
}
97
}
98
}
99
}
100
System.out.println("Test passed");
101
} catch (Exception e) {
102
exception = e;
103
}
104
}
105
106
}
107
108