<?xml version="1.0" ?>
<!DOCTYPE gui SYSTEM "gui.dtd">
<gui>
<script>
function processText(doc) {
    var _text = doc.getText(0,doc.getLength())
    var _i = parseInt(_text);
    if (_text.length==0 || isNaN(_i) || _text!=_i.toString()) {
        okButton.setEnabled(false);
        tf2.setText("");
    } else {
        // Is a number, display it x 10
        okButton.setEnabled(true);
        v = 10*+_i;
        tf2.setText(v.toString());
    }
}
function setDocListener(field) {
    var _doc = field.getDocument();
    _doc.onInsertUpdate = "processText(this);"
    _doc.onRemoveUpdate = "processText(this);"
}
</script>
<JFrame id="fixed" bg="gray" title="TextHandling Application" size="(300,190)" layout="null"
        script="this.onWindowClosing='java.lang.System.exit(0)'">
  <JTextField id="tf1" bounds="(20,40,260,25)" script="setDocListener(this)" />
  <JLabel text="Value 1:" bounds="(20,15,260,20)" labelFor="tf1" displayedMnemonic="v" />
  <JTextField id="tf2" bounds="(20,90,260,25)" />
  <JLabel text="Value 2:" bounds="(20,65,260,20)" labelFor="tf2" displayedMnemonic="a" />
  <JButton id = "ok" text="OK" bounds="(100,130,100,25)" 
        script="this.onAction='java.lang.System.exit(0)'"/>
</JFrame>
<script>
okButton=getById("ok");
okButton.setEnabled(false);
tf2=getById("tf2");
frame=getById("fixed");
frame.pack();
frame.setSize(300,190);
frame.show()
</script>
</gui>