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

too many key events being fired to keyListener

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.1
    • client-libs
    • None
    • x86
    • windows_nt



      Name: mc57594 Date: 01/20/97


      Pressing a "normal" key such as the letter "a" on the
      keyboard, causes the
      keyPressed method of a keyListener implementor to be called once as
      expected. If you
      press the ENTER key any time after pressing a "normal" key, the keyPressed
      method
      gets called twice for every ENTER key pressed! Note that pressing the CTRL
      key also
      causes subsequent ENTER key events to be fired twice.

      Here's a sample application to see the problem in action:

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

      public class KeyBugApp extends Frame implements KeyListener
      {
        public KeyBugApp()
        {
          addKeyListener (this);
        }

        public void paint (Graphics g)
        {
          g.drawString ("Look at the console output window for results!", 25,
      50);
        }

        public void keyPressed (KeyEvent e)
        {
          // this function should be called only once with every key pressed on
      the keyboard
          // press the letter 'a', then press ENTER and you'll see this function
      get called twice
          // after pressing ENTER
          System.out.println ("[keyPressed] "+e);
        }

        public void keyReleased (KeyEvent e)
        {
        }

        public void keyTyped (KeyEvent e)
        {
        }

        public static void main (String args[])
        {
          KeyBugApp frame = new KeyBugApp();
          frame.resize (320, 200);
          frame.show();
        }
      }
      ======================================================================

            rramsunw Ranganathan Ram (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: