/* * @(#)Test Button.java 1.0 96/12/16 Narao Itoh * * Copyright (c) 1996-1996 Nick_Family Co. All Rights Reserved. * */ import java.applet.Applet; import java.awt.*; import java.lang.*; /* Pass Word 入力 プログラム */ public class pass20 extends Applet { /* 型宣言 */ Label lab; String disp=""; long passdisp=2001; boolean flag=false; boolean flagout=true; /* 10キーパネルの作成 */ public void init(){ add(lab=new Label("Push Password ! ")); Panel p=new Panel(); p.setLayout(new GridLayout(4,3)); int i; for (i=1;i<10;i++){ p.add(new Button(Integer.toString(i))); } /* Ent/Clsキーをパネルに追加 */ p.add(new Button("Cls")); p.add(new Button("0")); p.add(new Button("Ent")); add(p); } /* マウスイベントの発生と処理 */ public boolean action(Event e,Object o){ Button b=(Button)e.target; if (flag){ disp=""; flag=false; } if ("Cls".equals(b.getLabel())) disp=""; else{ if ("Ent".equals(b.getLabel())){ if (Long.parseLong(disp)!=passdisp){ disp="Try Again !"; flag=true; } else{ disp="You are Great.!"; flag=true; flagout=false; } } else disp=disp+b.getLabel(); } lab.setText(disp); return flagout; } }