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

Disabled JMenu is selectable via mnemonic

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 1.3.1, 1.4.1
    • client-libs
    • tiger
    • x86
    • linux, windows_xp



      Name: rmT116609 Date: 10/23/2002


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

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Attached example demonstrates the problem.
      There is a disabled JMenu located in JMenuBar and it has
      enabled children. It is impossible to select this disabled
      menu either via mouse click or via up/down keyboard keys.
      But it is selectable via its mnemonic.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile attached example.
      2. Press Alt+F. It openes "File" menu
      3. Press "d". It selects "Disabled menu". Evidently it shouldn't.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // Example

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

      /**
       * @author Vladimir Kondratyev
       */
      public class Test {

        public static void main(String[] args){
          JFrame frame=new JFrame("Hello");
          frame.setBounds(100,100,300,200);
          frame.addWindowListener(
            new WindowAdapter(){
              public void windowClosing(WindowEvent e){
                System.exit(0);
              }
            }
          );

          JMenuBar menuBar=new JMenuBar();

          JMenu c=new JMenu("File");
          c.setMnemonic('F');

          c.add(new JMenuItem("Item1"));
          c.add(new JMenuItem("Item2"));

          JMenu disabledMenu=new JMenu("Disabled Menu");
          disabledMenu.add(new JMenuItem("sun"));
          disabledMenu.setMnemonic('D');

          disabledMenu.setEnabled(false);
          c.add(disabledMenu);
          c.add(new JMenuItem("Item3"));
          menuBar.add(c);

          frame.setJMenuBar(menuBar);

          frame.show();
        }

      }
      ---------- END SOURCE ----------
      (Review ID: 166125)
      ======================================================================

            kizune Alexander Zuev
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: