-
Bug
-
Resolution: Fixed
-
P2
-
1.4.0
-
b28
-
sparc
-
solaris_2.6
Name: dsR10051 Date: 10/17/2000
The method
protected void java.awt.Component.processKeyEvent(KeyEvent e)
is not called by event dispatch thread even if a KeyListener
object is registered via addKeyListener
(See JavaDoc for Component.processKeyEvent).
Here is a minimized test:
import java.awt.*;
import java.awt.event.*;
public class ComponentTest5 {
public static void main (String[] args) {
EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
ChildComponent chcomponent = new ChildComponent();
KeyEvent e = new KeyEvent(chcomponent, KeyEvent.KEY_RELEASED, (long)0, 0, KeyEvent.VK_UNDEFINED);
DummyKeyListener cl = new DummyKeyListener();
chcomponent.addKeyListener(cl);
eq.postEvent(e);
synchronized (chcomponent) {
while(!chcomponent.keyEventProcessed) {
try {
System.out.println("Waiting");
System.out.flush();
chcomponent.wait();
System.out.println("Waiting");
System.out.flush();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
System.exit(0);
}
}
class ChildComponent extends Component {
public ChildComponent() {
super();
}
boolean keyEventProcessed = false;
public synchronized void processKeyEvent(KeyEvent e) {
keyEventProcessed = true;
System.out.println("processKeyEvent called");
System.out.flush();
super.processKeyEvent(e);
System.out.println("processKeyEvent done");
System.out.flush();
notifyAll();
}
}
class DummyKeyListener extends KeyAdapter {
}
--- Output ---
%/net/sword/export3/JDK1.4.0beta-b36/solaris/bin/java -version
java version "1.4.0beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b36)
Java HotSpot(TM) Client VM (build 1.4beta-B36, mixed mode)
%/net/sword/export3/JDK1.4.0beta-b36/solaris/bin/java ComponentTest5
Waiting
^C
%
======================================================================
The method
protected void java.awt.Component.processKeyEvent(KeyEvent e)
is not called by event dispatch thread even if a KeyListener
object is registered via addKeyListener
(See JavaDoc for Component.processKeyEvent).
Here is a minimized test:
import java.awt.*;
import java.awt.event.*;
public class ComponentTest5 {
public static void main (String[] args) {
EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
ChildComponent chcomponent = new ChildComponent();
KeyEvent e = new KeyEvent(chcomponent, KeyEvent.KEY_RELEASED, (long)0, 0, KeyEvent.VK_UNDEFINED);
DummyKeyListener cl = new DummyKeyListener();
chcomponent.addKeyListener(cl);
eq.postEvent(e);
synchronized (chcomponent) {
while(!chcomponent.keyEventProcessed) {
try {
System.out.println("Waiting");
System.out.flush();
chcomponent.wait();
System.out.println("Waiting");
System.out.flush();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
System.exit(0);
}
}
class ChildComponent extends Component {
public ChildComponent() {
super();
}
boolean keyEventProcessed = false;
public synchronized void processKeyEvent(KeyEvent e) {
keyEventProcessed = true;
System.out.println("processKeyEvent called");
System.out.flush();
super.processKeyEvent(e);
System.out.println("processKeyEvent done");
System.out.flush();
notifyAll();
}
}
class DummyKeyListener extends KeyAdapter {
}
--- Output ---
%/net/sword/export3/JDK1.4.0beta-b36/solaris/bin/java -version
java version "1.4.0beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b36)
Java HotSpot(TM) Client VM (build 1.4beta-B36, mixed mode)
%/net/sword/export3/JDK1.4.0beta-b36/solaris/bin/java ComponentTest5
Waiting
^C
%
======================================================================
- relates to
-
JDK-4379917 Component.processFocusEvent is not called by event dispatch thread
- Resolved
-
JDK-6244370 Spec for Component.processFocusEvent/processKeyEvent doesn't match the implementation
- Open
-
JDK-4292099 AWT Event delivery to processEvent
- Closed