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

REGRESSION: Keyboard navigation in JMenuBar is incorrect.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs



      Name: rmT116609 Date: 01/10/2002


      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)

      DESCRIPTION OF THE PROBLEM :

      Wrong keyboard navigation into JMenuBar. In Swing application (see applied source), I have JMenuBar.
      Use F10 key to go in the first JMenu ("File"). Here all is OK. Try to go to JMenuItem ("Open") below. But
      when you press Down_Arrow key, the system menu is selected. This is a bug (which not exist in the JDK 1.3.1).
      Interesting side effect is when you see mentioned above system menu, if you press ESC and again ESC,
      keyboard navigation in the JMenuBar is OK.

      Now start the program again. Press F10 and try to select next JMenu ("Edit"). But when you press the Right_Arrow key
      nothing happen. This is a bug too (with JDK 1.3.1 the same code works OK).

      The problem is reproducible on Windows 2000, Windows Nt 4.0, Win 98 using JDK1.4.0-beta3.


      REGRESSION. Last worked in version 1.3.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Press F10
      2. Press down arrow key


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected : focus to first JMenuItem.
      Result : system menu is selected.

      This bug can be reproduced always.

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



      /**
       * This program demonstrate bug when using keyboard to navigate in menu
       * bar (with JDK 1.4 beta 3). Start the program, then press F10 and try to
       * select different menus. Next compile and run the same program under
       * JDK 1.3.1. Then you'll see the difference.
       *
       */
      public class MenuBug
      {
          /**
           * Creates new MenuBug object.
           *
           */
          public MenuBug()
          {
             // Create test frame
             javax.swing.JFrame f = new javax.swing.JFrame("Test menu bug");
             f.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
             f.setSize(400, 300);
             java.awt.Dimension dim = java.awt.Toolkit.getDefaultToolkit().
                 getScreenSize();
             f.setLocation(dim.width/2 - f.getWidth()/2, dim.height/2 -
                 f.getHeight());
          
             // Create menus
             JMenuBar mb = new JMenuBar();
             f.setJMenuBar(mb);

             JMenu mF = new JMenu("File");
             mb.add(mF);

             JMenuItem miO = new JMenuItem("Open");
             mF.add(miO);

             JMenuItem miE = new JMenuItem("Exit");
             mF.add(miE);

             JMenu mE = new JMenu("Edit");
             mb.add(mE);

             // Make all visible
             f.setVisible(true);
          } // constructor()



          /**
           * Entry point.
           *
           * @param args Command line arguments.
           */
          public static void main(String[] args)
          {
              try
              {
                  MenuBug app = new MenuBug();
              }
              catch(Throwable exc)
              {
                  exc.printStackTrace();
                  System.exit(-1);
              }
          } // main
      } // MenuBug


      ---------- END SOURCE ----------
      (Review ID: 137994)
      ======================================================================

            peterz Peter Zhelezniakov
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: