Why doesn't dispatchEvent(KeyEvent e) work in applets but does in applications?
Created May 4, 2012
John Zukowski This is actually the result of differences in Java runtime implementations between browser vendor. Microsoft seems to have implemented their event dispatching mechanism differently than the rest of the world. Sun's and Netscape's versions will use dispatchEvent() properly from an applet. You can try out the following test case and see for yourself:
// <applet code=TestCase width=500 height=200> // </applet> import java.applet.*; import java.awt.*; import java.awt.event.*; public class TestCase extends Applet { TextField t1 = new TextField(50); TextField t2 = new TextField(50); public void init() { add(t1); add(t2); t1.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { t2.dispatchEvent(e); } }); } }