JDK-8341173 : Middle mouse button is recognized as left mouse button
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 23
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2024-09-29
  • Updated: 2024-10-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24Unresolved
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 11 24H2 build 26100.1876 with KB5043178 patch.


A DESCRIPTION OF THE PROBLEM :
Latest windows 11 build 


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just execute my snippet and see that it prints "Left button clicked" even with middle mouse button.
This issue happens since the last Windows 11 24H2 update build 26100.1876
with KB5043178 patch.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
it should print "Middle button clicked"
ACTUAL -
it print "Left button clicked"

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

public class TrayIconExample {
    public static void main(String[] args) {
        if (SystemTray.isSupported()) {
            SystemTray tray = SystemTray.getSystemTray();
            Image image = Toolkit.getDefaultToolkit().createImage("icon.png");
            TrayIcon trayIcon = new TrayIcon(image, "Tray Demo");

            trayIcon.setImageAutoSize(true);
            trayIcon.setToolTip("Tray Icon Demo");

            trayIcon.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    if (e.getButton() == MouseEvent.BUTTON1) {
                        System.out.println("Left button clicked");
                    } else if (e.getButton() == MouseEvent.BUTTON3) {
                        System.out.println("Right button clicked");
                    } else if (e.getButton() == MouseEvent.BUTTON2) {
                        System.out.println("Middle button clicked");
                    }
                }
            });

            try {
                tray.add(trayIcon);
            } catch (AWTException e) {
                System.err.println("TrayIcon could not be added.");
            }
        } else {
            System.err.println("System tray not supported!");
        }
    }
}

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

FREQUENCY : always



Comments
Additional Information from submitter: ================================= Just to answer to: "When clicking scroll wheel on Windows 11, it returns "Left button clicked" Wheel equals to middle button on Windows if you don't remap the buttons, so no, you don't need a three button mouse.
14-10-2024

When clicking scroll wheel on Windows 11, it returns "Left button clicked" Need 3 button mouse to further verify the issue.
30-09-2024