import java.applet.*; import java.awt.*; public class textfld extends Applet { TextField plaintext = new TextField(20); TextField hiddentext = new TextField(10); Label plaintextvalue = new Label("----------------------------------"); Label hiddentextvalue = new Label("-----------------------------------"); public void init() { add(new Label("Type text in either text box and hit the enter key.")); add(plaintext); hiddentext.setEchoCharacter('*'); add(hiddentext); add(new Label("Or hit this button to")); add(new Button("Enter both fields")); add(new Label("at once.")); add(new Label("In the plain box you typed ")); add(plaintextvalue); add(new Label("In the hidden box you typed ")); add(hiddentextvalue); } public boolean action(Event evt, Object whatAction) { if (evt.target == plaintext) { plaintextvalue.setText(plaintext.getText()); return true; } if (evt.target == hiddentext) { hiddentextvalue.setText(hiddentext.getText()); return true; } if((evt.target instanceof Button)) { String buttonLabel = (String) whatAction; if (buttonLabel == "Enter both fields") { hiddentextvalue.setText(hiddentext.getText()); plaintextvalue.setText(plaintext.getText()); return true; } } return false; } }