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

Shift-clicks no longer detectable in 1.4 Beta


    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.4.0
    • Fix Version/s: 1.4.0
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
    • CPU:
    • OS:
      linux, windows_2000


      Name: bsC130419 Date: 06/25/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)

      I inspected my test code more closely with various JDKs, varying the way I am checking for the Shift key being pressed:

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

      public class x extends JFrame
          public static void main(String[] args) throws Exception
              new x();
          public x() throws Exception
              JPanel p = new JPanel(new GridLayout(1, 1));
              p.addMouseListener(new MouseAdapter() {
                  public void mousePressed(MouseEvent e)
      // if ((e.getModifiers() & Event.SHIFT_MASK) != 0)
      // if ((e.getModifiers() & InputEvent.SHIFT_MASK) != 0)
                        if (e.isShiftDown())
                  } );
              setSize(600, 400);

      The first (commented out) line will work in following JDKs:
      1) java full version "Linux_JDK_1.1.6_v5" (Blackdown's JDK)
      2) java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
      Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
      3) java version "1.3.0_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_02)
      Java HotSpot(TM) Client VM (build 1.3.0_02, mixed mode)
      4) java version "1.2"
      Classic VM (build Linux_JDK_1.2_pre-release-v2, native threads, sunwjit)
      (this one's from Blackdown, too)
      5) java full version "Linux_JDK_1.1.8_v1_green_threads"
      (another one from Blackdown)
      6) java full version "JDK 1.1.8 IBM build l118-20000325 (JIT enabled: jitc)"
      (IBM's port)
      7) java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
      Classic VM (build 1.3.0, J2RE 1.3.0 IBM build cx130-20000815 (JIT enabled: jitc))

      This line does NOT work in 1.4 Beta, however. While I cannot tell for sure that this is a bug -- the documentation of these SHIFT_MASK flags and the method getModifiers() is almost lacking -- this can certainly lead to portability problems in applications. The correct way of detecting Shift key status is shown in workaround.

      The second line does work in 3) for me, but I got a reply from a Sun engineer that it does not work in JDKs he tested it with.
      (Review ID: 127209)




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


              • Created: