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

Empty menus won't relinquish focus on mouse click

XMLWordPrintable

    • 7
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b66)
      Java HotSpot(TM) Client VM (build 16.0-b06, mixed mode, sharing)

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

      A DESCRIPTION OF THE PROBLEM :
      Clicking on a focused item in menu bar should toggle focus. This fails if menu contains no sub-elements. The first click grants focus but subsequent clicks have no effect.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Launch test app and click 'A' repeatedly. Note that focus never departs. Click 'B' to demonstrate proper behavior.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect focus to be revoked on second click of 'A' menu.
      ACTUAL -
      Focus remains.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JFrame;
      import javax.swing.JMenu;
      import javax.swing.JMenuBar;
      import javax.swing.JMenuItem;

      public class Test {
        public static void main(String[] pArgs) {
          final JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setJMenuBar(new JMenuBar());
          frame.getJMenuBar().add(new JMenu("A"));
          frame.getJMenuBar().add(new JMenu("B"));
          frame.getJMenuBar().getMenu(1).add(new JMenuItem("B1"));
          frame.pack();
          frame.setVisible(true);
        }
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: