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

Robot on Win2K is typing "SHIFT" instead of leaving it depressed.

    XMLWordPrintable

Details

    • x86
    • windows_2000

    Description

      I have noticed that this bug seems to only show up on Windows 2000 & Windows XP. I can't reproduce it on WinNT. The program attempts to do the following:

      press SHIFT
      press DELETE
      release DELETE
      release SHIFT

      However, on Win2K, it seems to do the following:

      press SHIFT
      release SHIFT
      press DELETE
      release DELETE
      press SHIFT
      release SHIFT

      This happened on JDK 1.3.1 so I believe that the bug has been there since the beginning of Robot. I tried the test on:

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

      The following program will demonstrate this problem.

      ------------------------------------ Cut Here ----------------------------------
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;

      public class WinRobotTest extends JFrame {

          private JPanel panel;
          private JTextField textField;
          private Robot robot;

          public static void main(String[] args) {
              WinRobotTest r = new WinRobotTest();
              r.runTest();
          }

          public WinRobotTest() {
              try {
                  robot = new Robot();
              } catch(Exception e) {
                  e.printStackTrace();
              }

              textField = new JTextField(20);
              textField.addKeyListener(new KeyListener() {
                  public void keyPressed(KeyEvent e) {
                      System.out.println("Key Pressed: " + e.getKeyCode());
                  }

                  public void keyReleased(KeyEvent e) {
                      System.out.println("Key Released: " + e.getKeyCode());
                  }

                  public void keyTyped(KeyEvent e) {
                      System.out.println("Key Typed: " + e.getKeyCode());
                  }
              });

              panel = new JPanel();
              panel.add(textField);

              getContentPane().add(panel);

              pack();
              setVisible(true);
          }

          public void runTest() {
              try {
                  Thread.sleep(2000);
              } catch(Exception e) {
                  e.printStackTrace();
              }

              textField.requestFocus();

              robot.keyPress(KeyEvent.VK_SHIFT);
              robot.keyPress(KeyEvent.VK_DELETE);
              robot.keyRelease(KeyEvent.VK_DELETE);
              robot.keyRelease(KeyEvent.VK_SHIFT);
          }
      }
      ------------------------------------ Cut Here ----------------------------------
             
      ###@###.### 2001-11-20
      Swing Test Development

      Attachments

        Activity

          People

            serb Sergey Bylokhov
            elousunw Edmund Lou (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: