/********************************************************************************** * * * Password JAVA Applet * * ( Pwd10e.java ) * * Author : Seiichi Inoue * **********************************************************************************/ /********************** << Imported package class definition >> *******************/ import java.applet.Applet; /* Applet packages */ import java.applet.AppletContext; /* AppletContext packages */ import java.awt.*; /* All of the Abstract Window Toolkit packages */ import java.net.URL; /* URL packages */ import java.net.MalformedURLException; /* MalformedURLException packages */ /************************** <<Oneself of class definition>> ***********************/ // Class name : Pwd10e // Access control : public( Access possibility even from which class ) // Extends class : Applet public class Pwd10e extends Applet { /************************* << Class attribute of definition >> ********************/ TextField input; /* Password input field */ String s = null; /* Input-output information */ URL secretURL = null; /* URL information */ /***************************** << Information setting >> **************************/ //@Password setting String password = "inoue"; /* Within Alpha-numeral 20 letter */ //@Jump URL String setURL = "http://hobby_elec.piclist.com/e_java29_3.htm"; /***************** << Class of method (implementation procedure) >> ***************/ // /******** Initialization (init) method *********/ public void init() { input = new TextField( 20 ); /* Input field preparation */ input.setEchoCharacter('*'); /* Password echo * */ add( input ); /* Action surveillance addition */ try { /* Interruption confirmation */ secretURL = new URL ( setURL ); /* URL object preparation */ } catch ( MalformedURLException e ) {} /* Interruption processing */ } /* End of init method */ /********** Action surveillance method *********/ public boolean action(Event e,Object o) { s = (String)o; /* Input letter reading */ if ( s.equals ( password ) ) { /* Input and password match ? */ s = null; /* Error display clear */ if ( secretURL != null ) /* It is normal URL ? */ getAppletContext().showDocument( secretURL ); /* Jump to URL */ } else { /* Discordance */ s = "Password Error"; /* Set Password Error */ repaint(); /* Prt instruct of Password Error */ } return true; } /* End of action surveillance */ /*********** Drawing (paint) method ************/ public void paint( Graphics g ) { g.setColor( Color.white ); /* Background color setting */ g.fillRect( 0,0,180,50 ); /* Paint backcolor */ g.setColor( Color.black ); /* Letter color setting */ g.drawString( s,50,40 ); /* Drawing of the letter */ } /* End of paint method */ } /* End of class setting */ /********************************************************************************** * End of Password JAVA Applet * **********************************************************************************/