The applet shows in the Java Console the events it receives from text entry into the TextField.
Tablet input produces different events in the Microsoft and Sun Java Virtual Machines (JVMs). Enter a single character and see the following TextField events fired and the following input read in the TextField:
| Event | Microsoft JVM (3810) | Sun JVM (1.5 RC) | ||||||
| Fired by TIP input | Can read latest input | Fired by TIP input | Can read latest input | |||||
| keyPressed | Yes | No | No | No | ||||
| keyReleased | Yes | Yes | No | No | ||||
| keyTyped | Yes | Yes | Yes | No | ||||
| textValueChanged | Yes | Yes | Yes | Yes | ||||
It is not clear whether either of these implementations can be called incorrect, but the differences raise pitfalls for Java programmers trying to support the Windows XP Tablet edition environment. The Microsoft implementation has better backwards compatibility for programs not written with Tablet PC input in mind, but it seems likely that the Sun approach is following official recommendations. Apple has a similar implementation.
Other Tablet PC Java problems:
If you have any insights, workarounds or comments about this test page please contact Mickey Segal. A listing of many Java resources is at this link.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class tablet_events extends Applet implements ActionListener, KeyListener, TextListener {
TextField textField;
public void init()
{
setBackground(new Color(225,225, 255));
textField = new TextField(20);
textField.addActionListener(this);
textField.addKeyListener(this);
textField.addTextListener(this);
add(textField);
textField.requestFocus();
}
public void actionPerformed(ActionEvent ae)
{
System.out.println("actionPerformed: " + textField.getText());
}
public void keyPressed(KeyEvent ke)
{
System.out.println("keyPressed: " + textField.getText());
}
public void keyReleased(KeyEvent ke)
{
System.out.println("keyReleased: " + textField.getText());
}
public void keyTyped(KeyEvent ke)
{
System.out.println("keyTyped: " + textField.getText());
}
public void textValueChanged(TextEvent te)
{
System.out.println("textValueChanged: " + textField.getText());
}
} // END OF Class tablet_events