TextField feedback by color and nearby Labels

As detailed at this link, supporting Tablet input to TextFields means problems with providing feedback to the user by means of messages within the TextField.  Illustrated in the applet above is a workaround by using textValueChanged only to change the color of the text in the TextField, not use setText, which calls textValueChanged recursively.  Additional feedback is provided with a nearby Label, which takes up space but is understandable to the user and compatible with Tablet input.

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.

Source code:

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class tablet_events4 extends Applet implements TextListener {

TextField textField;
Label label;

public void init()
{
    setBackground(new Color(225,225, 255));
    textField = new TextField(20);
    textField.addTextListener(this);
    add(textField);
    label = new Label(" ");
    label.setForeground(Color.red);
    add(label);
    textField.requestFocus();
}

void displayCorrectness()
{
    if (getDoubleFromString(textField.getText()) < -0.01)
    {
        textField.setForeground(Color.red);
        label.setText("Error");
    }
    else
    {
        textField.setForeground(Color.black);
        label.setText(" ");
    }
}

public void textValueChanged(TextEvent te)
{
    displayCorrectness();
}

double getDoubleFromString(String s)
{
    s = s.trim();
    if (s.equals("") || s == null) return (-1.0);
    try
    {
        return (Double.valueOf(s).doubleValue());
    }
    catch (Exception e)
    {
        return(-1.0);
    }
}
} // END OF Class tablet_events4