public class REDemo extends Applet implements TextListener 
{
...fieldRE.addTextListener(this);
fieldMatch.addTextListener(this);
// Initial UI update
textValueChanged(null);
....
public void textValueChanged(TextEvent e)
    {
        // If it's a generic update or the regexp changed...
        if (e == null || e.getSource() == fieldRE)
        {
            // Update regexp
            updateRE(fieldRE.getText());
        }        // We always need to update the match results
        updateMatch(fieldMatch.getText());
    }
...
}