jdk/test/javax/swing/JLabel/6596966/bug6596966.java
author rupashka
Wed, 27 Apr 2011 13:43:22 +0400
changeset 9491 f7970a9d4656
parent 9217 f795ef267353
child 15636 0eeacbf451a7
permissions -rw-r--r--
7039403: Could not compile test/javax/swing/JLabel/6596966/bug6596966.java Reviewed-by: malenkov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9217
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
     1
/*
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
     4
 *
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
     8
 *
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    13
 * accompanied this code).
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    14
 *
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    18
 *
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    21
 * questions.
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    22
 */
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    23
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    24
/* @test
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    25
   @bug 6596966
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    26
   @summary Some JFileChooser mnemonics do not work with sticky keys
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    27
   @run main bug6596966
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    28
   @author Pavel Porvatov
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    29
*/
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    30
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    31
9491
f7970a9d4656 7039403: Could not compile test/javax/swing/JLabel/6596966/bug6596966.java
rupashka
parents: 9217
diff changeset
    32
import sun.awt.SunToolkit;
f7970a9d4656 7039403: Could not compile test/javax/swing/JLabel/6596966/bug6596966.java
rupashka
parents: 9217
diff changeset
    33
9217
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    34
import javax.swing.*;
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    35
import java.awt.*;
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    36
import java.awt.event.KeyEvent;
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    37
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    38
public class bug6596966 {
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    39
    private static JFrame frame;
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    40
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    41
    private static JLabel label;
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    42
    private static JButton button;
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    43
    private static JComboBox comboBox;
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    44
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    45
    public static void main(String[] args) throws Exception {
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    46
        Robot robot = new Robot();
9491
f7970a9d4656 7039403: Could not compile test/javax/swing/JLabel/6596966/bug6596966.java
rupashka
parents: 9217
diff changeset
    47
        SunToolkit toolkit = (SunToolkit) SunToolkit.getDefaultToolkit();
9217
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    48
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    49
        SwingUtilities.invokeAndWait(new Runnable() {
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    50
            public void run() {
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    51
                button = new JButton("Button");
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    52
                comboBox = new JComboBox();
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    53
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    54
                label = new JLabel("Label");
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    55
                label.setDisplayedMnemonic('L');
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    56
                label.setLabelFor(comboBox);
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    57
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    58
                JPanel pnContent = new JPanel();
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    59
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    60
                pnContent.add(button);
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    61
                pnContent.add(label);
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    62
                pnContent.add(comboBox);
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    63
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    64
                frame = new JFrame();
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    65
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    66
                frame.add(pnContent);
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    67
                frame.pack();
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    68
                frame.setVisible(true);
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    69
            }
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    70
        });
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    71
9491
f7970a9d4656 7039403: Could not compile test/javax/swing/JLabel/6596966/bug6596966.java
rupashka
parents: 9217
diff changeset
    72
        toolkit.realSync();
9217
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    73
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    74
        robot.keyPress(KeyEvent.VK_ALT);
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    75
        robot.keyPress(KeyEvent.VK_L);
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    76
9491
f7970a9d4656 7039403: Could not compile test/javax/swing/JLabel/6596966/bug6596966.java
rupashka
parents: 9217
diff changeset
    77
        toolkit.realSync();
9217
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    78
9491
f7970a9d4656 7039403: Could not compile test/javax/swing/JLabel/6596966/bug6596966.java
rupashka
parents: 9217
diff changeset
    79
        toolkit.getSystemEventQueue().postEvent(new KeyEvent(label, KeyEvent.KEY_RELEASED,
9217
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    80
                EventQueue.getMostRecentEventTime(), 0, KeyEvent.VK_L, 'L'));
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    81
9491
f7970a9d4656 7039403: Could not compile test/javax/swing/JLabel/6596966/bug6596966.java
rupashka
parents: 9217
diff changeset
    82
        toolkit.realSync();
9217
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    83
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    84
        try {
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    85
            SwingUtilities.invokeAndWait(new Runnable() {
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    86
                public void run() {
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    87
                    if (!comboBox.isFocusOwner()) {
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    88
                        throw new RuntimeException("comboBox isn't focus owner");
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    89
                    }
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    90
                }
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    91
            });
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    92
        } finally {
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    93
            robot.keyRelease(KeyEvent.VK_ALT);
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    94
        }
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    95
    }
f795ef267353 6596966: Some JFileChooser mnemonics do not work with sticky keys
rupashka
parents:
diff changeset
    96
}