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

[macos] Mouse Released event is not fired if mouse released outside window

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      os_x

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Java 17.0.1, Java 17, Java 16.0.2
      MacOS 11.6.1
      verified on two different machines with the exact same OS and Java versions

      A DESCRIPTION OF THE PROBLEM :
      On Big Sur, there will be no mouseReleased event if the mouse is released outside of the frame containing the component and the mouse is moving while released. I see there are some older bugs like this, but they are marked as fixed or not reproducible.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the code.
      Click in the window and drag the mouse to outside the window. Release while moving the mouse quickly.
      Try again if the problem does not occur.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect each "mouse pressed" in the output to be followed by a "mouse released".

      ACTUAL -
      It's possible to get many "mouse pressed" in the output with no "mouse released".

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

      public class MouseReleasedBug {
         public static void main(String[] args) {
            SwingUtilities.invokeLater(()->go());
         }
         public static void go() {
            JFrame f = new JFrame();
            JPanel p = new JPanel();
            p.addMouseListener(
               new MouseAdapter() {
                  public void mousePressed(MouseEvent e) {
                     System.out.println("press");
                  }
                  public void mouseReleased(MouseEvent e) {
                     System.out.println("release");
                  }
               });
            f.add(p);
            f.setSize(600, 600);
            f.setVisible(true);
         }
      }

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

      FREQUENCY : always


        Attachments

          Activity

            People

            Assignee:
            achung Alisen Chung
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: