-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.1
-
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();
}
}
======================================================================