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

Regression: JButton does not give up keyboard focus when JMenu is open

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.3.0
    • client-libs



      Name: skT88420 Date: 02/01/2000


      java version "1.3beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
      Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)

      Steps to reproduce:

      1. Compile and run the source code below under Windows.
         You should see a single frame with a button and a menu bar. The button
         should have the keyboard focus.
      2. Click on "Menu" in the menu bar. There should be one menu item, currently
         selected.
      3. Hit return to select that menu item. Instead, a message will be printed
         to standard out saying that the button had been pressed, and that the
         menu item was not activated.

      I tested this using JDK 1.3beta, but not RC1 (yet). I also tested it using
      the Metal L&F; the problem doesn't seem to manifest in it. Only the Windows
      L&F seems to have the problem. (I haven't tested Motif.)

      This bug might be related to bugs 4108907 and/or 4157941.

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

      public class test
      {
        public static void main (String[] args)
        {
          try {
            UIManager.setLookAndFeel
              (UIManager.getSystemLookAndFeelClassName());
          } catch (Exception ex) {}
          JFrame frame = new JFrame ("frame");
          JMenuBar mbar = new JMenuBar();
          JMenu menu = new JMenu ("Menu");

          JMenuItem item = menu.add (new JMenuItem("MenuItem"));
          item.addActionListener (new ActionListener() {
            public void actionPerformed (ActionEvent e)
            { System.out.println ("menuitem"); }
          });

          mbar.add (menu);

          frame.setJMenuBar (mbar);

          JButton button = new JButton ("pushme");
          button.addActionListener (new ActionListener() {
            public void actionPerformed (ActionEvent e)
            { System.out.println ("pushme"); }
          });

          Container cpane = frame.getContentPane();
          cpane.add (BorderLayout.CENTER, button);
          frame.pack();
          frame.show();
        }
      }
      (Review ID: 100671)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: