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

SwingUtilities.isMiddleMouseButton does not work with ALT/Meta keys

XMLWordPrintable

    • b08
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.7.0"
      Java(TM) SE Runtime Environment (build 1.7.0-b147)
      Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux xxxx 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:24 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Because of bitfield definitions in InputEvent, when e.g. CTRL-ALT-left mouse click occurs, SwingUtilities.isMiddleMouseButton returns true, which is inappropriate.

      Likewise when Meta+left mouse is clicked, the event may be falsely reported as right button event by SwingUtilities.isRightMouseButton.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      attach MouseListener to a swing component
      hold ctrl+alt keys and left-click some swing component. in listener.mouseClicked() observe the value of SwingUtilities.isMiddleMouseButton().

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      SwingUtilities.isMiddleMouseButton() should return false (left button was clicked)
      ACTUAL -
      SwingUtilities.isMiddleMouseButton() should returns true


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Calling code must not use SwingUtilities, but directly check by event.getButton() == BUTTON2. Effectively renders the SwingUtilities methods unusable (they are unreliable).

            rupashka Pavel Porvatov (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: