home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-09-27 | 1.0 KB | 41 lines |
- // OpenDialog.java
- // pop up dialog and check user's input
- import java.awt.*;
-
- public class OpenDialog extends Frame {
- OpenSesame opensesame;
- public final static String MAGICSPELL = "open sesame";
- TextField passwd = null;
-
- OpenDialog(OpenSesame owner){
- super(MAGICSPELL); // Title name is the magic spell
- setLayout(new FlowLayout());
- add(new Label("Magic Spell?"));
- passwd = new TextField(20);
- passwd.setEchoCharacter('*'); // hides the real input text
- add(passwd);
- pack();
- opensesame = owner;
- }
-
- public boolean handleEvent(Event e){
- switch(e.id){
- case e.ACTION_EVENT:
- if(passwd == e.target){
- if(((String)e.arg).equals(MAGICSPELL)){
- opensesame.openDoor();
- this.hide();
- return true;
- }
- passwd.setText("");
- return true;
- }
- break;
- default:
- break;
- }
- return false;
- }
- }
-
-