Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7172652

With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin

    XMLWordPrintable

Details

    • b68
    • x86
    • windows_7

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "1.7.0_02"
        Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
        Java HotSpot(TM) Client VM (build 22.0-b10, mixed mode, sharing)


        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows [Version 6.1.7601]

        A DESCRIPTION OF THE PROBLEM :
        If a Label control is configured with a mnemonic, the Alt/Key combination does not move focus to the text field configured in the "labelFor" property.
        Instead the focus goes to the first menu.

        REGRESSION. Last worked in version 6u31

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1) Run the attached sample code.
        2) Click on the “First name” text field.
        3) Press Alt/L to move the focus to the “Last name” text field.


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Focus should move to “Last name” text field instead of moving to menu “FirstMenu”.

        ACTUAL -
        Focus is not moved to “Last name” text field. Instead the focus is moved to menu “FirstMenu”.


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        package com.samples;

        import java.awt.BorderLayout;
        import java.awt.FlowLayout;

        import javax.swing.JDesktopPane;
        import javax.swing.JFrame;
        import javax.swing.JInternalFrame;
        import javax.swing.JLabel;
        import javax.swing.JMenu;
        import javax.swing.JMenuBar;
        import javax.swing.JPanel;
        import javax.swing.JTextField;
        import javax.swing.UIManager;

        public class Sample extends JDesktopPane{

        JLabel firstLbl = new JLabel("First name");
        JLabel lastLbl = new JLabel("Last name");
        JMenuBar menuBar = new JMenuBar();

        JTextField firstTxtFld = new JTextField(20);
        JTextField lastTxtFld = new JTextField(20);

        public Sample() {

        boolean resizable = true;
        boolean closeable = true;
        boolean maximizable = true;
        boolean iconifiable = true;
        String title = "Frame Title";
        JInternalFrame iframe = new JInternalFrame(title, resizable, closeable, maximizable, iconifiable);

        // Set an initial size
        int width = 200;
        int height = 50;
        iframe.setSize(width, height);

        // By default, internal frames are not visible; make it visible
        iframe.setVisible(true);

        JPanel pane = new JPanel();
        pane.setLayout(new FlowLayout());

        pane.add(firstLbl);
        pane.add(firstTxtFld);
        pane.add(lastLbl);
        pane.add(lastTxtFld);

        firstLbl.setLabelFor(firstTxtFld);
        firstLbl.setDisplayedMnemonic('F');

        lastLbl.setLabelFor(lastTxtFld);
        lastLbl.setDisplayedMnemonic('L');

        iframe.getContentPane().add(pane);
        iframe.setJMenuBar(menuBar);
        JMenu m = new JMenu("FirstMenu");
        //m.setMnemonic('i');
        menuBar.add(m);
        this.add(iframe);
        }

        public static void main(String[] args) throws Exception {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        JFrame frame = new JFrame();
        frame.getContentPane().add(new Sample (), BorderLayout.CENTER);
        frame.setSize(300, 300);
        frame.setVisible(true);
        }

        }

        ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

                ssadetsky Semyon Sadetsky (Inactive)
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: