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

REGRESSION: First letter navigation in JTree/JList interferes with mnemonics

    XMLWordPrintable

Details

    • hopper
    • generic
    • generic
    • Verified

    Description



      Name: jl125535 Date: 01/02/2002


      FULL PRODUCT VERSION :
      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)


      FULL OPERATING SYSTEM VERSION :
      Windows Millennium [Version 4.90.3000]



      A DESCRIPTION OF THE PROBLEM :
      Typing a letter while a JTree or JList has focus now
      makes the selection jump to the first/next node/item
      whose text starts with that letter. While this is a
      nice feature, in its current form it interferes with
      other features such as menu mnemonics (see steps
      to reproduce).

        Suggested fix:
      Only enable JTree/JList letter navigation when the user
      doesn't press any modifier keys such as ALT or CTRL.


      REGRESSION. Last worked in version 1.3.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      TestCase1 displays a JTree
          Click on the first node then type ALT+F
            (Note: sometimes it's necessary to do this twice
             before the effect can be seen)
          The File menu will be opened
            - OK
          The selection will change to 'food'
            - not OK since the user only intended to open the
      File menu

      TestCase2 displays a JList
          Click on the first item then type ALT+F
            (Note: sometimes it's necessary to do this twice
             before the effect can be seen)
          The File menu will be opened
            - OK
          The selection will change to 'freak'
            - not OK since the user only intended to open the
      File menu

      This bug can be reproduced always.

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

      public class TestCase1 extends JFrame {
        public TestCase1() {
          super("TestCase1");
          
          JMenu menu = new JMenu("File");
          menu.setMnemonic('F');
          
          JMenuItem menuItem = new JMenuItem("Dummy");
          menu.add(menuItem);
          
          JMenuBar menuBar = new JMenuBar();
          menuBar.add(menu);
          
          setJMenuBar(menuBar);
          
          setContentPane(new JTree());
          
          setSize(new Dimension(400, 400));
          setLocation((getToolkit().getScreenSize().width -
      getWidth()) / 2,
            ((getToolkit().getScreenSize().height) - getHeight
      ()) / 2);
        }
        
        public static void main(String[] args) {
          new TestCase1().setVisible(true);
        }
      }

      ------------------------------------------------------------
      -----

      import java.awt.*;
      import javax.swing.*;

      public class TestCase2 extends JFrame {
        public TestCase2() {
          super("TestCase2");
          
          JMenu menu = new JMenu("File");
          menu.setMnemonic('F');
          
          JMenuItem menuItem = new JMenuItem("Dummy");
          menu.add(menuItem);
          
          JMenuBar menuBar = new JMenuBar();
          menuBar.add(menu);
          
          setJMenuBar(menuBar);
          
          setContentPane(new JList(new String[]
      {"anaheim", "bill", "chicago", "dingo", "ernie", "freak"}));
          
          setSize(new Dimension(400, 400));
          setLocation((getToolkit().getScreenSize().width -
      getWidth()) / 2,
            ((getToolkit().getScreenSize().height) - getHeight
      ()) / 2);
        }
        
        public static void main(String[] args) {
          new TestCase2().setVisible(true);
        }
      }

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

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

      (Review ID: 137697)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              apikalev Andrey Pikalev
              jleesunw Jon Lee (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: