//Password.java //This version is modal //Andy Harris, 05/00 import java.awt.*; import java.applet.*; import java.awt.event.*; import Prompt; public class Password extends Applet implements ActionListener{ Frame theFrame = new Frame("This is a frame"); Prompt p = new Prompt(theFrame); Button btnLogin = new Button("Log in"); Button btnCloseFrame = new Button("Close Frame"); public void init(){ theFrame.setLayout(new FlowLayout()); theFrame.add(btnLogin); theFrame.add(btnCloseFrame); theFrame.setVisible(true); theFrame.setSize(200,200); btnLogin.addActionListener(this); btnCloseFrame.addActionListener(this); } // end init public void actionPerformed(ActionEvent e){ if (e.getSource() == btnLogin){ p.ask("What's the password?"); while (!(p.getResponse().equals("java"))){ p.say("Hint: it is 'java'"); p.ask("What's the password?"); } // end while p.say("You got it!!"); } else { theFrame.setVisible(false); theFrame.dispose(); } // end if } // end actionPerformed } // end class def