Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JFileChooser/8080628/bug8080628.java
38854 views
/*1* Copyright (c) 2015, 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;2728import sun.swing.SwingUtilities2;2930/*31* @test32* @bug 808062833* @summary No mnemonics on Open and Save buttons in JFileChooser.34* @author Alexey Ivanov35* @run main bug808062836*/37public class bug8080628 {38public static final String[] MNEMONIC_KEYS = new String[] {39"FileChooser.saveButtonMnemonic",40"FileChooser.openButtonMnemonic",41"FileChooser.cancelButtonMnemonic",42"FileChooser.directoryOpenButtonMnemonic"43};4445public static final Locale[] LOCALES = new Locale[] {46new Locale("en"),47new Locale("de"),48new Locale("es"),49new Locale("fr"),50new Locale("it"),51new Locale("ja"),52new Locale("ko"),53new Locale("pt", "BR"),54new Locale("sv"),55new Locale("zh", "CN"),56new Locale("zh", "TW")57};5859private static volatile Exception exception;6061public static void main(String[] args) throws Exception {62SwingUtilities.invokeAndWait(new Runnable() {63@Override64public void run() {65runTest();66}67});6869if (exception != null) {70throw exception;71}72}7374private static void runTest() {75try {76LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();77for (LookAndFeelInfo info : lafInfo) {78UIManager.setLookAndFeel(info.getClassName());7980for (Locale locale : LOCALES) {81for (String key : MNEMONIC_KEYS) {82int mnemonic = SwingUtilities2.getUIDefaultsInt(key, locale);83if (mnemonic != 0) {84throw new RuntimeException("No mnemonic expected (" + mnemonic + ") " +85"for '" + key + "' " +86"in locale '" + locale + "' " +87"in Look-and-Feel '"88+ UIManager.getLookAndFeel().getClass().getName() + "'");89}90}91}92}93System.out.println("Test passed");94} catch (Exception e) {95exception = e;96}97}9899}100101102