Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JFileChooser/4524490/bug4524490.java
38853 views
/*1* Copyright (c) 2012, 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*/2223/*24* @test25* @bug 452449026* @summary Tests if in JFileChooser, ALT+L does not bring focus to 'Files' selection list in Motif LAF27* @author Konstantin Eremin28* @library ../../regtesthelpers29* @library ../../../../lib/testlibrary30* @build Util jdk.testlibrary.OSInfo31* @run main bug452449032*/33import java.awt.Robot;34import java.awt.Toolkit;35import java.awt.event.KeyEvent;36import javax.swing.*;37import jdk.testlibrary.OSInfo;3839public class bug4524490 {4041private static JFileChooser fileChooser;4243public static void main(String[] args) throws Exception {44Robot robot = new Robot();45robot.setAutoDelay(50);4647UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");4849SwingUtilities.invokeLater(new Runnable() {5051public void run() {52fileChooser = new JFileChooser();53fileChooser.showOpenDialog(null);54}55});5657robot.waitForIdle();5859if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) {60Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L);61} else {62Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_L);63}64checkFocus();65}6667private static void checkFocus() throws Exception {68SwingUtilities.invokeAndWait(new Runnable() {6970@Override71public void run() {72JList list = (JList) Util.findSubComponent(fileChooser, "javax.swing.JList");73System.out.println("list focus: " + list.isFocusOwner());74if (!list.isFocusOwner()) {75throw new RuntimeException("Focus is not transfered to the Folders list.");76}77}78});79}80}818283