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

REGRESSION: Old modifiers reset when instantiating a MouseEvent

XMLWordPrintable

    • x86
    • windows_2000

      Name: gm110360 Date: 02/04/2004


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

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]
      Service Pack 3

      A DESCRIPTION OF THE PROBLEM :
      The "old modifiers" ALT_MASK and META_MASK are reset if
      combined with BUTTON1_MASK when instantiating a MouseEvent.

      In this situation, the constructor of MouseEvent calls
      setNewModifiers(), which resets the BUTTON2_MASK and
      BUTTON3_MASK. Unfortunately these corresponds to ALT_MASK
      and META_MASK.

      REGRESSION. Last worked in version 1.3.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the attached program


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      With JDK 1.4.1, the output is:
      isAltDown: false

      While with JDK 1.3.1 it is:
      isAltDown: true

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.event.MouseEvent;
      import javax.swing.JButton;

      public class MouseEventTest {

        public MouseEventTest() {
          MouseEvent e = new MouseEvent(new JButton(),
                                        MouseEvent.MOUSE_PRESSED,
                                        1,
                                        MouseEvent.BUTTON1_MASK | MouseEvent.ALT_MASK,
                                        10,
                                        10,
                                        1,
                                        false);

          boolean isAltDown =
              (e.getModifiers() & MouseEvent.ALT_MASK) == MouseEvent.ALT_MASK;
          System.out.println( "isAltDown: " + isAltDown);
          System.exit(0);
        }

        public static void main(String[] args) {
          MouseEventTest mouseEventTest1 = new MouseEventTest();
        }
      }
      ---------- END SOURCE ----------

      Release Regression From : 1.3.1_10
      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: 181632)
      ======================================================================

            dav Andrei Dmitriev (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: