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

Focused JMenu prevents other components of gaining focus.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 6
    • 1.4.1
    • client-libs



      Name: jk109818 Date: 11/11/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]
      Service Pack 3

      A DESCRIPTION OF THE PROBLEM :
      If I select a JMenu and click afterwards on a component, for example a
      button, this component doesn't get the focus.

      This is strange,
      because the button looks a short time like it was pressed.
      If you try the
      same with a textfield, you get first an "Input"-Mousecursor while moving
      the mouse over the textfield, but clicking on it does nothing.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Start the example
      2. Click on the first texfield
      3. Click on the
      menu
      4. Click on the second textfield / button

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      What I expected: Clicked components gain focus (if focusable) and
      buttons fire actions.

      What happens: The component which was focused
      before the menu was selected is focused again.

      Seems it has something
      to do with the new Focusmanager and temporary FocusEvents, even though I
      didn't tested it.


      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class Test {
        
        public static final void
      main(String[] params) {
          JFrame frame = new JFrame("Test");
          
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          JMenuBar menuBar = new
      JMenuBar();
          JMenu menu = new JMenu("2. Click me");
          JMenuItem item = new
      JMenuItem("Focus");
          menu.add(item);
          menuBar.add(menu);
          
      frame.setJMenuBar(menuBar);
          frame.getContentPane().setLayout(new FlowLayout());
          
      frame.getContentPane().add(new JTextField("1. Click me", 20));
          
      frame.getContentPane().add(new JTextField("3. Click me", 20));
          
      frame.getContentPane().add(new JButton("or me") {
            protected void
      fireActionPerformed(ActionEvent e) {
              JOptionPane.showMessageDialog(this, "Button
      clicked");
            }
          });
          frame.pack();
          frame.show();
        }
        
      }
      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      Using an adjusted focusmanager?
      (Review ID: 164999)
      ======================================================================

            draskinsunw Daniel Raskin (Inactive)
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: