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

MouseEvent.getModifiers() returns inconsistent results across platforms

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1.3, 1.1.4, 1.1.5, 1.1.6, 1.1.8_003, 1.2.0, 1.3.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Subcomponent:
    • CPU:
      x86, sparc
    • OS:
      solaris_2.5.1, solaris_2.6, windows_95, windows_nt

      Description

      orig synopsis:
          "MouseEvent.getModifiers() returns inconsistent
              results on Solaris and Windows NT"

      Name: diC59631 Date: 10/06/97


      For a variable of class java.awt.event.MouseEvent,
      the method getModifiers() return the following
      inconsistent results on Solaris and Windows NT:

                            Solaris Windows NT *

      LEFT MOUSE_PRESSED 0 16 DIFFERENT !
      MIDDLE MOUSE_PRESSED 8 20
      REIGHT MOUSE_PRESSED 4 4

      LEFT MOUSE_DRAGGED 16 0 DIFFERENT !
      MIDDLE MOUSE_DRAGGED 8 4 DIFFERENT !
      REIGHT MOUSE_DRAGGED 4 4


      * Tested with a 2 button mouse. Pressing left and right mouse button
        simultaneously simluate middle mouse button. It also gives funny
        clickCount values (single click is reported as double click);
        but that's what you can expect from simulating a 3 button mouse
        with simultaneous clicking two mouse button.


      Use the following program to test it:

      // MouseEventTester.java
      // John Immerk{\ae}r ###@###.### 1997 October 6


      import java.awt.*;
      import java.awt.event.*;


      public class MouseEventTester extends Frame {

        public MouseEventTester() {
          super("MouseEventTester");
          add( new MouseEventComponent() );
          pack();
          setVisible(true);
        }

        public static void main(String[] args) {
          new MouseEventTester().setVisible(true);
          System.out.println("BUTTON1_MASK = " + MouseEvent.BUTTON1_MASK);
          System.out.println("BUTTON2_MASK = " + MouseEvent.BUTTON2_MASK);
          System.out.println("BUTTON3_MASK = " + MouseEvent.BUTTON3_MASK);
        }

      }

        

      class MouseEventComponent extends Component
                                implements MouseListener, MouseMotionListener
      {

        public MouseEventComponent() {
          setSize(getPreferredSize());
          addMouseListener(this);
          addMouseMotionListener(this);
        }


        public Dimension getPreferredSize() {
          return new Dimension(200,200);
        }


        ///// MouseListener methods /////

        public void mouseClicked(MouseEvent event) {
          System.out.println(event);
        }

        public void mouseEntered(MouseEvent event) {
          System.out.println(event);
        }

        public void mouseExited(MouseEvent event) {
          System.out.println(event);
        }

        public void mousePressed(MouseEvent event) {
          System.out.println(event);
        }

        public void mouseReleased(MouseEvent event) {
          System.out.println(event);
        }


        ///// MouseMotionListener methods /////

        public void mouseDragged(MouseEvent event) {
          System.out.println(event);
        }

        public void mouseMoved(MouseEvent event) {
          System.out.println(event);
        }

      }
      ======================================================================

      diC59631 1998-01-07

      Some more info. On Solaris you can get a different modified on press and release of a button!

      With the following example code:

      /* an applet with the following html file:
      <HTML>
      <HEAD>
      <TITLE>Testing View class</TITLE>
      </HEAD>
      <BODY >
      <H1>Testing View class</H1>
      <HR></HR>
      <CENTER>
      <APPLET CODEBASE= "file:///u/rjkroege/projects/java/" CODE="rjk.drawtest.Test" WIDTH=600 HEIGHT=500></APPLET>
      </CENTER>
      </BODY>
      </HTML>
      */
      package rjk.drawtest;

      import java.applet.*;
      import java.awt.*;
      import java.awt.swing.*;
      import java.io.*;
      import java.awt.event.*;


      public class Test extends Applet implements MouseListener {

      /* MouseListener Interface */
      public void mouseClicked(MouseEvent e ) {
      }

       
        public void mouseEntered(MouseEvent e) {
        }
       
      public void mouseExited(MouseEvent e) {
      }

      public void mousePressed(MouseEvent e) {
      System.out.println( e );
      }

      public void mouseReleased(MouseEvent e) {
      System.out.println( e );
      }

      public void init( ) {
              addMouseListener( this );
      }



      } // end class

      Clicking on the applet with the three mouse buttons:

      java.awt.event.MouseEvent[MOUSE_PRESSED,(284,255),mods=0,clickCount=1] on panel1
      java.awt.event.MouseEvent[MOUSE_RELEASED,(284,255),mods=16,clickCount=1] on panel1
      java.awt.event.MouseEvent[MOUSE_PRESSED,(216,212),mods=8,clickCount=1] on panel1
      java.awt.event.MouseEvent[MOUSE_RELEASED,(216,212),mods=8,clickCount=1] on panel1
      java.awt.event.MouseEvent[MOUSE_PRESSED,(216,212),mods=4,clickCount=1] on panel1
      java.awt.event.MouseEvent[MOUSE_RELEASED,(216,211),mods=4,clickCount=1] on panel1


      Note the following:
      java.awt.event.MouseEvent[MOUSE_PRESSED,(284,255),mods=0,clickCount=1] on panel1
                                                        ^^^^^^
      java.awt.event.MouseEvent[MOUSE_RELEASED,(284,255),mods=16,clickCount=1] on panel1 ^^^^^^^

      ==========================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bchristi Brent Christian
                Reporter:
                dindrigo Daniel Indrigo (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: