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

Incorrect mouse event modifiers with scroll mice

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.1
    • client-libs
    • x86
    • windows_2000



      Name: yyT116575 Date: 06/13/2001


      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      This problems seems to exist only on scroll mice. The modifiers for buttons
      other than the left one are incorrect. For instance pressing the middle
      button (i.e., the wheel) results in the 'Alt Ctrl Button2' modifier being
      "posted" and similarly for the right button. I am seeing this behaviour on
      a bog-standard Logitech scroll mouse; it is probably generic.

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class T2 extends JScrollPane implements MouseListener {

        private JTextArea jt;
          
        public T2() {
          super();
          setViewportView(jt = new JTextArea());
          jt.setEditable(false);
          jt.addMouseListener(this);
          setPreferredSize(new Dimension(150,100));
        }

        public void mouseClicked (MouseEvent e) { }
        public void mouseReleased(MouseEvent e) { }
        public void mouseEntered (MouseEvent e) { }
        public void mouseExited (MouseEvent e) { }
        public void mousePressed (MouseEvent e) {
          int mod = e.getModifiers();
          int button =
              ((mod & MouseEvent.BUTTON1_MASK) != 0) ? 1 :
              ((mod & MouseEvent.BUTTON2_MASK) != 0) ? 2 :
              ((mod & MouseEvent.BUTTON3_MASK) != 0) ? 3 : -1;
          StringBuffer buf = new StringBuffer();
          if ((mod & InputEvent.ALT_MASK) != 0) buf.append("Alt ");
          if ((mod & InputEvent.CTRL_MASK) != 0) buf.append("Ctrl ");
          if ((mod & InputEvent.META_MASK) != 0) buf.append("Meta ");
          if ((mod & InputEvent.SHIFT_MASK) != 0) buf.append("Shift ");
          buf.append("Button "+button+"\n");
          jt.append(buf.toString());
        }

        public static final void main(String[] argv) {
          JFrame jf = new JFrame();
          jf.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              System.exit(0);
            }
          });
          jf.getContentPane().add(new T2(), BorderLayout.CENTER);
          jf.pack();
          jf.setVisible(true);
        }
      }
      (Review ID: 126455)
      ======================================================================

            bchristi Brent Christian
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: