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

mouseReleased not sent to components in popup submenu

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description

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


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Any component added to a submenu inside of a JPopupMenu does not receive mouseReleased events. In most cases, this prevents the component from functioning properly.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the code below, and run it.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect that the button will function properly, and that the mouse listener will print the following to stdout:

      pressed
      released
      clicked
      ACTUAL -
      The button is stuck down, and the following is printed to stdout:

      pressed
      clicked

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package com.mindiq.mindiqweb.devlite.outline;

      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.awt.event.MouseEvent;
      import java.awt.event.MouseListener;

      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JMenu;
      import javax.swing.JPopupMenu;

      public class BugTest extends JFrame
      {
          private MouseListener ml = new MouseListener() {
              public void mouseEntered(MouseEvent e) { }
              public void mouseExited(MouseEvent e) { }

              public void mouseClicked(MouseEvent e)
              {
                  System.out.println("clicked");
              }

              public void mousePressed(MouseEvent e)
              {
                  System.out.println("pressed");
              }

              public void mouseReleased(MouseEvent e)
              {
                  System.out.println("released");
              }
          };

          public BugTest()
          {
              super("Test Popup mouseReleased");

              JButton startButton = new JButton("Start");

              startButton.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e)
                  {
                      JPopupMenu popup = new JPopupMenu();
                      JMenu middleMenu = new JMenu("Middle");
                      JButton endButton = new JButton("End");

                      endButton.addMouseListener(ml);

                      middleMenu.add(endButton);
                      popup.add(middleMenu);
                      popup.show(BugTest.this, 20, 20);
                  }
              });

              getContentPane().add(startButton);
              pack();
              setVisible(true);
          }

          public static void main(String[] args)
          {
              new BugTest();
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      I wish I knew.
      ###@###.### 2005-1-28 06:49:26 GMT

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              jssunw Jitender S (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: