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