Path: blob/master/test/jdk/javax/swing/JFileChooser/8080628/bug8080628.java
41153 views
/*1* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.util.Locale;24import javax.swing.SwingUtilities;25import javax.swing.UIManager;26import javax.swing.UIManager.LookAndFeelInfo;27import javax.swing.UnsupportedLookAndFeelException;2829import sun.swing.SwingUtilities2;3031/*32* @test33* @bug 808062834* @summary No mnemonics on Open and Save buttons in JFileChooser.35* @author Alexey Ivanov36* @modules java.desktop/sun.swing37* @run main bug808062838*/39public class bug8080628 {40public static final String[] MNEMONIC_KEYS = new String[] {41"FileChooser.saveButtonMnemonic",42"FileChooser.openButtonMnemonic",43"FileChooser.cancelButtonMnemonic",44"FileChooser.directoryOpenButtonMnemonic"45};4647public static final Locale[] LOCALES = new Locale[] {48new Locale("en"),49new Locale("de"),50new Locale("es"),51new Locale("fr"),52new Locale("it"),53new Locale("ja"),54new Locale("ko"),55new Locale("pt", "BR"),56new Locale("sv"),57new Locale("zh", "CN"),58new Locale("zh", "TW")59};6061private static volatile Exception exception;6263public static void main(String[] args) throws Exception {64SwingUtilities.invokeAndWait(new Runnable() {65@Override66public void run() {67runTest();68}69});7071if (exception != null) {72throw exception;73}74}7576private static void runTest() {77try {78LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();79for (LookAndFeelInfo info : lafInfo) {80try {81UIManager.setLookAndFeel(info.getClassName());82} catch (final UnsupportedLookAndFeelException ignored) {83continue;84}8586for (Locale locale : LOCALES) {87for (String key : MNEMONIC_KEYS) {88int mnemonic = SwingUtilities2.getUIDefaultsInt(key, locale);89if (mnemonic != 0) {90throw new RuntimeException("No mnemonic expected (" + mnemonic + ") " +91"for '" + key + "' " +92"in locale '" + locale + "' " +93"in Look-and-Feel '"94+ UIManager.getLookAndFeel().getClass().getName() + "'");95}96}97}98}99System.out.println("Test passed");100} catch (Exception e) {101exception = e;102}103}104105}106107108