I coded it this way but this throws an exception.
import java.awt.event.*;
import java.awt.*;
import java.util.*;
public class RobotDemo {
String string2Print;
RobotDemo(String str) {
Hashtable ht = new Hashtable();
ht.put("A", new Integer(KeyEvent.VK_A));
ht.put("B", new Integer(KeyEvent.VK_B));
.................
.................
ht.put("Z", new Integer(KeyEvent.VK_Z));
string2Print = str;
try {
Robot rob = new Robot();
for (int i = 0; i < string2Print.length(); i++) {
String charStr = string2Print.substring(i, 1);
Integer ic = (Integer)ht.get(charStr);
rob.keyPress(ic.intValue());
rob.delay(1000);
}
rob.keyPress(KeyEvent.VK_ENTER);
} catch (AWTException awte) {
}
}
public static void main(String args[]) {
new RobotDemo("THEQUICKBROWNFOXJUMPSOVERALAZYDOG");
}
}
The output is given below.
C:\jdk1.5.0u1\bin>JAVA RobotDemo
TException in thread "main" java.lang.NullPointerException
at RobotDemo.<init>(RobotDemo.java:45)
at RobotDemo.main(RobotDemo.java:56)
The version of the jdk i am using is
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b0

Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
What may be the problem?
-Sameer