author | serb |
Fri, 16 Feb 2018 12:24:38 -0800 | |
changeset 49090 | 82c1fe23c469 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
30951
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
1 |
/* |
49090
82c1fe23c469
8196196: Headful tests should not be run in headless mode
serb
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
30951
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
4 |
* |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
8 |
* |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
13 |
* accompanied this code). |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
14 |
* |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
18 |
* |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
21 |
* questions. |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
22 |
*/ |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
23 |
|
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
24 |
import java.util.Locale; |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
25 |
import javax.swing.SwingUtilities; |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
26 |
import javax.swing.UIManager; |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
27 |
import javax.swing.UIManager.LookAndFeelInfo; |
49090
82c1fe23c469
8196196: Headful tests should not be run in headless mode
serb
parents:
47216
diff
changeset
|
28 |
import javax.swing.UnsupportedLookAndFeelException; |
30951
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
29 |
|
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
30 |
import sun.swing.SwingUtilities2; |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
31 |
|
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
32 |
/* |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
33 |
* @test |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
34 |
* @bug 8080628 |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
35 |
* @summary No mnemonics on Open and Save buttons in JFileChooser. |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
36 |
* @author Alexey Ivanov |
31660
1a4e2e5c15e1
8130125: [TEST_BUG] add @modules to the several client tests unaffected by the automated bulk update
yan
parents:
30951
diff
changeset
|
37 |
* @modules java.desktop/sun.swing |
30951
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
38 |
* @run main bug8080628 |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
39 |
*/ |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
40 |
public class bug8080628 { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
41 |
public static final String[] MNEMONIC_KEYS = new String[] { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
42 |
"FileChooser.saveButtonMnemonic", |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
43 |
"FileChooser.openButtonMnemonic", |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
44 |
"FileChooser.cancelButtonMnemonic", |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
45 |
"FileChooser.directoryOpenButtonMnemonic" |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
46 |
}; |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
47 |
|
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
48 |
public static final Locale[] LOCALES = new Locale[] { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
49 |
new Locale("en"), |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
50 |
new Locale("de"), |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
51 |
new Locale("es"), |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
52 |
new Locale("fr"), |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
53 |
new Locale("it"), |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
54 |
new Locale("ja"), |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
55 |
new Locale("ko"), |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
56 |
new Locale("pt", "BR"), |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
57 |
new Locale("sv"), |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
58 |
new Locale("zh", "CN"), |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
59 |
new Locale("zh", "TW") |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
60 |
}; |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
61 |
|
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
62 |
private static volatile Exception exception; |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
63 |
|
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
64 |
public static void main(String[] args) throws Exception { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
65 |
SwingUtilities.invokeAndWait(new Runnable() { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
66 |
@Override |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
67 |
public void run() { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
68 |
runTest(); |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
69 |
} |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
70 |
}); |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
71 |
|
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
72 |
if (exception != null) { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
73 |
throw exception; |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
74 |
} |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
75 |
} |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
76 |
|
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
77 |
private static void runTest() { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
78 |
try { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
79 |
LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels(); |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
80 |
for (LookAndFeelInfo info : lafInfo) { |
49090
82c1fe23c469
8196196: Headful tests should not be run in headless mode
serb
parents:
47216
diff
changeset
|
81 |
try { |
82c1fe23c469
8196196: Headful tests should not be run in headless mode
serb
parents:
47216
diff
changeset
|
82 |
UIManager.setLookAndFeel(info.getClassName()); |
82c1fe23c469
8196196: Headful tests should not be run in headless mode
serb
parents:
47216
diff
changeset
|
83 |
} catch (final UnsupportedLookAndFeelException ignored) { |
82c1fe23c469
8196196: Headful tests should not be run in headless mode
serb
parents:
47216
diff
changeset
|
84 |
continue; |
82c1fe23c469
8196196: Headful tests should not be run in headless mode
serb
parents:
47216
diff
changeset
|
85 |
} |
30951
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
86 |
|
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
87 |
for (Locale locale : LOCALES) { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
88 |
for (String key : MNEMONIC_KEYS) { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
89 |
int mnemonic = SwingUtilities2.getUIDefaultsInt(key, locale); |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
90 |
if (mnemonic != 0) { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
91 |
throw new RuntimeException("No mnemonic expected (" + mnemonic + ") " + |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
92 |
"for '" + key + "' " + |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
93 |
"in locale '" + locale + "' " + |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
94 |
"in Look-and-Feel '" |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
95 |
+ UIManager.getLookAndFeel().getClass().getName() + "'"); |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
96 |
} |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
97 |
} |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
98 |
} |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
99 |
} |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
100 |
System.out.println("Test passed"); |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
101 |
} catch (Exception e) { |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
102 |
exception = e; |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
103 |
} |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
104 |
} |
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
105 |
|
0383ab2b6d21
8080628: No mnemonics on Open and Save buttons in JFileChooser
aivanov
parents:
diff
changeset
|
106 |
} |