JDK-4767690 : REGRESSION:Menu mnemonics don't work properly when submenu is first item in menu
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-10-23
  • Updated: 2002-10-23
  • Resolved: 2002-10-23
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 10/23/2002


FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)


FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]

EXTRA RELEVANT SYSTEM CONFIGURATION :
This was tested with and without "Hide keyboard navigation
indicators until I use the Alt key" checked.

A DESCRIPTION OF THE PROBLEM :
If a menu in the menu bar has a submenu as its first item,
then keypresses will activate items in the submenu, not the
outer menu.

REGRESSION.  Last worked in version 1.4

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run the attached program.
2. Press Alt-M, then press E.
3. Press Alt-M, then press C.

EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected:
When Alt-M then E is pressed, the "Exit" command is fired.
When Alt-M then C is pressed, the "Choice" command is fired.

Actual:
When Alt-M then E is pressed, the "Other choice" command is
fired.
When Alt-M then C is pressed, the menu remains open and
nothing is fired.


REPRODUCIBILITY :
This bug can be reproduced always.

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

public class MenuRegression2 extends JFrame implements ActionListener
{
  public static void maien (String[] args)
  {
    new MenuRegression2();
  }

  public MenuRegression2()
  {
    super();

    WindowListener l = new WindowAdapter()
    {
      public void windowClosing(WindowEvent e) {System.exit(0);}
    };
    addWindowListener (l);

    setTitle ("Menu testing");

    JMenuBar t_menuBar = new JMenuBar();
    setJMenuBar(t_menuBar);
    JMenu menu1 = new JMenu("Menu");
    menu1.setMnemonic('M');
    t_menuBar.add(menu1);

    JMenu menu2 = new JMenu("Submenu");
    menu2.setMnemonic('B');
    menu1.add(menu2);

    JMenuItem menuItem = new JMenuItem("Other choice");
    menuItem.setMnemonic('E');
    menuItem.addActionListener(this);
    menu2.add(menuItem);

    menuItem = new JMenuItem("Choice");
    menuItem.setMnemonic('C');
    menuItem.addActionListener(this);
    menu1.add(menuItem);

    menuItem = new JMenuItem("Exit");
    menuItem.setMnemonic('E');
    menuItem.addActionListener(this);
    menu1.add(menuItem);

    pack();
    show();
  }

  public void actionPerformed (ActionEvent A)
  {
    System.out.println ("Action performed on " + A.getActionCommand());
  }
}

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

Release Regression From : 1.4.0_02
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Review ID: 166146) 
======================================================================

Comments
EVALUATION Duplicate of 4750590 - which is fixed in 1.4.2 and will be putback in a couple weeks. Which means that this fix will make it into 1.4.2.b06 or b07. ###@###.### 2002-10-23
23-10-2002