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

CTRL_DOWN_MASK trouble [with backward compatibility]

XMLWordPrintable

    • beta2
    • generic
    • generic
    • Verified



      Name: bsC130419 Date: 06/08/2001


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

      The new CTRL_DOWN_MASK in java.awt.event.InputEVent breaks code
      that relied on the (e.getModifiers() & CTRL_MASK) != 0 idiom to
      know whether CTRL was active. Specifically, with java 1.3.0,
      pressing the left mouse button and CTRL key together would
      result in modifiers = 18, hence (e.getModifiers() & CTRL_MASK)
      = 2 whereas it now results in modifiers = 8336, hence
      (e.getModifiers() & CTRL_MASK) = 0.

      So, is this a bug or did you deliberately break back-compatibility?

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

      public class T extends JPanel implements MouseListener {

          public T() {
      super();
      setPreferredSize(new Dimension(100,100));
      addMouseListener(this);
          }

          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 down3 = mod & InputEvent.CTRL_MASK;
      int down4 = mod & InputEvent.CTRL_DOWN_MASK;
      System.out.println(mod+" "+down3+" "+down4);
          }

          public static final void main(String[] argv) {
      T t = new T();
      JFrame jf = new JFrame();
      jf.getContentPane().add(t, BorderLayout.CENTER);
      jf.pack();
      jf.setVisible(true);
          }
      }
      (Review ID: 126080)
      ======================================================================

            ssisunw Ssi Ssi (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: