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

Alt tab with Windows L&F moves focus to the application menubar

XMLWordPrintable

    • b53
    • 6
    • b79
    • x86
    • windows_2000

      Name: ks84122 Date: 04/02/2003


      The problem below is reproducible with JDK 1.4.1 and 1.4.2 build 19 on windows 2000. The problem isn't reproducible with some of the earlier builds of 1.4.2 (build 03, for example). However, it seems to have resurfaced again in the latest builds.

      Original description from Borland:
      ==================================

      Very frequently only with the Windows Look and Feel doing an Alt-Tab from one application to another and back results in focus being moved to the first menu item.

      Run the program below. Focus starts out in the text field. Use Alt-Tab to move to another application (e.g. Notepad) and back multiple times. Usually by the second or third time the File menu item is selected. On some machines happens every time.

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class Frame1 extends JFrame {
        JPanel contentPane;
        JMenuBar jMenuBar1 = new JMenuBar();
        JMenu jMenuFile = new JMenu();
        JMenuItem jMenuFileExit = new JMenuItem();
        JMenu jMenuHelp = new JMenu();
        JMenuItem jMenuHelpAbout = new JMenuItem();
        GridBagLayout gridBagLayout1 = new GridBagLayout();
        JLabel jLabel1 = new JLabel();
        JTextField jTextField1 = new JTextField();

        //Construct the frame
        public Frame1() {
          contentPane = (JPanel) this.getContentPane();
          contentPane.setLayout(gridBagLayout1);

          this.setTitle("Frame Title");
          jMenuFile.setText("File");
          jMenuFileExit.setText("Exit");

          jMenuHelp.setText("Help");
          jMenuHelpAbout.setText("About");

          jMenuFile.add(jMenuFileExit);
          jMenuHelp.add(jMenuHelpAbout);
          jMenuBar1.add(jMenuFile);
          jMenuBar1.add(jMenuHelp);

          jLabel1.setLabelFor(jTextField1);
          jLabel1.setText("Label");
          jLabel1.setDisplayedMnemonic('l');
          jTextField1.setText("text");

          contentPane.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          contentPane.add(jTextField1, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
          this.setJMenuBar(jMenuBar1);
        }


        public static void main(String[] args) {
          try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
           }
          catch (Exception ex) {
            ex.printStackTrace();
          }

          Frame1 frame = new Frame1();
          frame.validate();
          frame.setSize(200, 100);
          frame.setLocation(200, 200);
          frame.setVisible(true);
        }
      }
      (Review ID: 165756)
      ======================================================================
      Please refer to 6458497. I have verified (on mustang build 93) a report that highlights that the focus still stays on the menu bar. This can be reproduced with the test case in 4841881 by quickly pressing the ALT-TAB buttons.

            son Oleg Sukhodolsky (Inactive)
            ksoshals Kirill Soshalskiy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: