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

Reopen #4841881: Alt tab with Windows L&F moves focus to the application menubar

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b03
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.6.0-rc"
        Java(TM) SE Runtime Environment (build 1.6.0-rc-b94)
        Java HotSpot(TM) Client VM (build 1.6.0-rc-b94, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [Version 5.1.2600]

        A DESCRIPTION OF THE PROBLEM :
        When switching from a Java application to another application using Alt-TAB, focus shifts to the JMenuBar. This means that when the user returns to the Java application, the menu bar has the focus, even if the user never intended to use the menu bar.

        The problem only seems to occur when the time gap between hitting Alt and then TAB is short. Anything under about 0.5s on my system shifts focus to the menu bar and leaves the focus there.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1) Compile and run the sample program, which has a JFrame and JMenuBar
        2) Quickly press Alt-TAB to switch to another application; make sure that the time gap between pressing Alt and TAB is small

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The menu bar on the Java application should not be highlighted.
        ACTUAL -
        The menu bar on the Java application is highlighted. After switching back to the application and then repeating the steps, the focus shift is undone, and now the menu bar is no longer highlighted.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.*;
        import javax.swing.*;

        public class AltTab {
          public static void main(String[] args) {
            try {
                UIManager.setLookAndFeel(UIManager
                     .getSystemLookAndFeelClassName());
            } catch(Exception e) {
            }
            JFrame frame = new JFrame("Alt-Tab Frame");
            JMenuBar menuBar = new JMenuBar();
            frame.setJMenuBar(menuBar);
            JMenu fileMenu = new JMenu("File");
            char fileMenuMnemonic = 'F';
            fileMenu.setMnemonic(fileMenuMnemonic);
            menuBar.add(fileMenu);
            frame.setSize(100,100);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
          }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        A workaround posted in the comments to bug #4841881 (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4841881) works for the test case, but as the submitter mentioned, has potentially undesirable side effects. The workaround doesn't work for a larger application I have created. The problem existed in Java v.1.4.x, disappeared in v.1.5, and has reappeared in snapshots of v.1.6.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                son Oleg Sukhodolsky (Inactive)
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: