jdk/test/javax/swing/plaf/basic/BasicLabelUI/bug7172652.java
author martin
Wed, 02 Sep 2015 14:11:50 -0700
changeset 32427 c22b7e41adf3
parent 30939 59e64fa7aec2
child 46151 5fa789776f7d
permissions -rw-r--r--
8134984: Text files should end in exactly one newline Summary: automated fixup of newlines at end-of-file via the usual perl one-liner Reviewed-by: chegar, sherman
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30939
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
     1
/*
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
     4
 *
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
     7
 * published by the Free Software Foundation.
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
     8
 *
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    13
 * accompanied this code).
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    14
 *
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    18
 *
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    21
 * questions.
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    22
 */
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    23
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    24
/* @test
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    25
   @bug 7172652
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    26
   @summary With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    27
   @author Semyon Sadetsky
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    28
   @library /lib/testlibrary
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    29
   @build jdk.testlibrary.OSInfo
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    30
   @run main bug7172652
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    31
  */
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    32
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    33
import javax.swing.*;
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    34
import javax.swing.event.ChangeEvent;
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    35
import javax.swing.event.ChangeListener;
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    36
import java.awt.*;
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    37
import java.awt.event.KeyEvent;
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    38
import jdk.testlibrary.OSInfo;
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    39
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    40
public class bug7172652  {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    41
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    42
    private static JMenu menu;
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    43
    private static JFrame frame;
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    44
    private static Boolean selected;
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    45
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    46
    public static void main(String[] args) throws Exception {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    47
        if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    48
            System.out.println("ok");
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    49
            return;
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    50
        }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    51
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    52
        SwingUtilities.invokeAndWait(new Runnable() {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    53
            @Override
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    54
            public void run() {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    55
                setup();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    56
            }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    57
        });
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    58
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    59
        test();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    60
        SwingUtilities.invokeLater(new Runnable() {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    61
            @Override
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    62
            public void run() {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    63
                frame.dispose();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    64
            }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    65
        });
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    66
    }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    67
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    68
    private static void test() throws Exception {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    69
        SwingUtilities.invokeAndWait(new Runnable() {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    70
            @Override
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    71
            public void run() {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    72
                menu.getModel().addChangeListener(new ChangeListener() {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    73
                    @Override
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    74
                    public void stateChanged(ChangeEvent e) {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    75
                        selected = menu.isSelected();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    76
                    }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    77
                });
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    78
            }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    79
        });
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    80
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    81
        Robot robot = new Robot();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    82
        robot.setAutoDelay(200);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    83
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    84
        robot.keyPress(KeyEvent.VK_ALT);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    85
        robot.keyPress(KeyEvent.VK_F);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    86
        robot.keyRelease(KeyEvent.VK_F);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    87
        robot.keyRelease(KeyEvent.VK_ALT);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    88
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    89
        robot.waitForIdle();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    90
        if( selected != null ) {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    91
            throw new RuntimeException("Menu is notified selected= " + selected);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    92
        }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    93
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    94
        robot.keyPress(KeyEvent.VK_ALT);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    95
        robot.keyPress(KeyEvent.VK_F);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    96
        robot.keyRelease(KeyEvent.VK_F);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    97
        robot.keyRelease(KeyEvent.VK_ALT);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    98
        if( selected != null ) {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
    99
            throw new RuntimeException("Menu is notified selected= " + selected);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   100
        }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   101
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   102
        robot.waitForIdle();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   103
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   104
        robot.keyPress(KeyEvent.VK_ALT);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   105
        robot.keyPress(KeyEvent.VK_F);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   106
        robot.keyRelease(KeyEvent.VK_F);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   107
        robot.keyRelease(KeyEvent.VK_ALT);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   108
        if( selected != null ) {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   109
            throw new RuntimeException("Menu is notified selected= " + selected);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   110
        }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   111
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   112
        robot.waitForIdle();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   113
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   114
        robot.keyPress(KeyEvent.VK_ALT);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   115
        robot.keyPress(KeyEvent.VK_F);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   116
        robot.keyRelease(KeyEvent.VK_F);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   117
        robot.keyRelease(KeyEvent.VK_ALT);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   118
        if( selected != null ) {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   119
            throw new RuntimeException("Menu is notified selected= " + selected);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   120
        }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   121
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   122
        robot.waitForIdle();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   123
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   124
        System.out.printf("ok");
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   125
    }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   126
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   127
    private static void setup() {
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   128
        JLabel firstLbl = new JLabel("First name");
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   129
        JLabel lastLbl = new JLabel("Last name");
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   130
        JMenuBar menuBar = new JMenuBar();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   131
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   132
        JTextField firstTxtFld = new JTextField(20);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   133
        JTextField lastTxtFld = new JTextField(20);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   134
        JDesktopPane desktopPane = new JDesktopPane();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   135
        JInternalFrame iframe = new JInternalFrame("A frame", true, true, true, true);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   136
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   137
        // Set an initial size
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   138
        iframe.setSize(200, 220);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   139
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   140
        // By default, internal frames are not visible; make it visible
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   141
        iframe.setVisible(true);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   142
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   143
        JPanel pane = new JPanel();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   144
        pane.setLayout(new FlowLayout());
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   145
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   146
        pane.add(firstLbl);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   147
        pane.add(firstTxtFld);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   148
        pane.add(lastLbl);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   149
        pane.add(lastTxtFld);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   150
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   151
        firstLbl.setLabelFor(firstTxtFld);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   152
        firstLbl.setDisplayedMnemonic('F');
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   153
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   154
        lastLbl.setLabelFor(lastTxtFld);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   155
        lastLbl.setDisplayedMnemonic('L');
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   156
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   157
        iframe.getContentPane().add(pane);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   158
        iframe.setJMenuBar(menuBar);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   159
        menu = new JMenu("FirstMenu");
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   160
        //m.setMnemonic('i');
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   161
        menuBar.add(menu);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   162
        desktopPane.add(iframe);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   163
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   164
        frame = new JFrame();
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   165
        frame.setUndecorated(true);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   166
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   167
        frame.getContentPane().add(desktopPane);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   168
        frame.setSize(300, 300);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   169
        frame.setVisible(true);
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   170
    }
59e64fa7aec2 7172652: With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
ssadetsky
parents:
diff changeset
   171
32427
c22b7e41adf3 8134984: Text files should end in exactly one newline
martin
parents: 30939
diff changeset
   172
}