4912N/A/*
4912N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4912N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4912N/A *
4912N/A * This code is free software; you can redistribute it and/or modify it
4912N/A * under the terms of the GNU General Public License version 2 only, as
4912N/A * published by the Free Software Foundation.
4912N/A *
4912N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4912N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4912N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4912N/A * version 2 for more details (a copy is included in the LICENSE file that
4912N/A * accompanied this code).
4912N/A *
4912N/A * You should have received a copy of the GNU General Public License version
4912N/A * 2 along with this work; if not, write to the Free Software Foundation,
4912N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4912N/A *
4912N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4912N/A * or visit www.oracle.com if you need additional information or have any
4912N/A * questions.
4912N/A */
4912N/A
4912N/A/*
4912N/A * @test
4912N/A * @bug 4524490
4912N/A * @summary Tests if in JFileChooser, ALT+L does not bring focus to 'Files' selection list in Motif LAF
4912N/A * @library ../../regtesthelpers
4912N/A * @build Util
4912N/A * @author Konstantin Eremin
4912N/A * @run main bug4524490
4912N/A */
4912N/Aimport java.awt.Robot;
4912N/Aimport java.awt.Toolkit;
4912N/Aimport java.awt.event.KeyEvent;
4912N/Aimport javax.swing.*;
4912N/Aimport sun.awt.OSInfo;
4912N/Aimport sun.awt.SunToolkit;
4912N/A
4912N/Apublic class bug4524490 {
4912N/A
4912N/A private static JFileChooser fileChooser;
4912N/A
4912N/A public static void main(String[] args) throws Exception {
4912N/A SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
4912N/A Robot robot = new Robot();
4912N/A robot.setAutoDelay(50);
4912N/A
4912N/A UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
4912N/A
4912N/A SwingUtilities.invokeLater(new Runnable() {
4912N/A
4912N/A public void run() {
4912N/A fileChooser = new JFileChooser();
4912N/A fileChooser.showOpenDialog(null);
4912N/A }
4912N/A });
4912N/A
4912N/A toolkit.realSync();
4912N/A
4912N/A if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) {
4912N/A Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L);
4912N/A } else {
4912N/A Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_L);
4912N/A }
4912N/A checkFocus();
4912N/A }
4912N/A
4912N/A private static void checkFocus() throws Exception {
4912N/A SwingUtilities.invokeAndWait(new Runnable() {
4912N/A
4912N/A @Override
4912N/A public void run() {
4912N/A JList list = (JList) Util.findSubComponent(fileChooser, "javax.swing.JList");
4912N/A System.out.println("list focus: " + list.isFocusOwner());
4912N/A if (!list.isFocusOwner()) {
4912N/A throw new RuntimeException("Focus is not transfered to the Folders list.");
4912N/A }
4912N/A }
4912N/A });
4912N/A }
4912N/A}