import java.awt.*; import java.applet.Applet; import java.net.*; public class Applet1 extends Applet { TextField passwordField; boolean badPass = false; URL passwordURL; public void init() { setBackground(Color.white); try { passwordURL = new URL("http://javamagic.hypermart.net/index.htm"); } catch (MalformedURLException err) { passwordURL = this.getDocumentBase(); } add(new Label("Password:")); passwordField = new TextField(10); passwordField.setEchoCharacter('*'); add(passwordField); } public void paint(Graphics g) { if (badPass) { g.drawString("Incorrect Password--Please try again",200,40); } } public boolean action(Event e, Object arg) { if (e.target instanceof TextField) { if (passwordField.getText().equals("javamagic")) { getAppletContext().showDocument(passwordURL); } else { badPass = true; repaint(); } return true; } return false; } }