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

REGRESSION: Putting a JButton in a submenu of a JPopupMenu causes glitch

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2000, windows_xp

      Description

      Name: rmT116609 Date: 02/09/2004


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

      ADDITIONAL OS VERSION INFORMATION :
      Windows 2000 SP4

      A DESCRIPTION OF THE PROBLEM :
      Placing a JButton in a submenu of a JPopupMenu causes a strange glitch where clicking the button causes it to get pressed down but it doesn't fire an action event and stays stuck pressed down.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Run included code under jdk 1.5
      2) Right-click anywhere in the JFrame that appears
      3) Select the subMenu item, which opens up a sub menu
      4) Click the "Click me" button

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Button gets pressed and then pops up again and an actionEvent is fired (console should print "Clicked")
      ACTUAL -
      Button gets pressed, stays stuck pressed and no event is fired

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.event.MouseAdapter;
      import java.awt.event.MouseEvent;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.awt.*;

      public class PopupButtonTest
      {

        public static void main(String[] args)
        {
          JFrame jf = new JFrame("PopupButtonTest");

          jf.getContentPane().addMouseListener(new MouseAdapter()
          {
            public void mouseClicked(MouseEvent e)
            {
              handle(e);
            }

            public void mousePressed(MouseEvent e)
            {
              handle(e);
            }

            public void mouseReleased(MouseEvent e)
            {
              handle(e);
            }

            private void handle(MouseEvent e)
            {
              if (e.isPopupTrigger())
              {
                JPopupMenu jpm = new JPopupMenu();
                JButton but = new JButton("Click me");
                but.addActionListener(new ActionListener()
                {
                  public void actionPerformed(ActionEvent e)
                  {
                    System.out.println("Clicked!");
                  }

                });
                JMenu jm = new JMenu("subMenu");
                jm.add(but);
                jpm.add(jm);
                jpm.show((Component) e.getSource(), e.getX(), e.getY());
              }
            }

          });

          jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          jf.setSize(100, 100);
          jf.setVisible(true);
        }


      }

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

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

      (Incident Review ID: 237606)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: