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

Middle mouse button is recognized as left mouse button

XMLWordPrintable

    • generic
    • windows

      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


            honkar Harshitha Onkar
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: