📄 removetest.java
字号:
/* * 这个程序主要是想remove控件.java * * Created on 2004年9月22日, 下午6:44 *//** * * @author litertiger */import java.awt.event.*;import java.awt.*;public class removeTest extends java.applet.Applet implements ActionListener{ TextField t1,t2,t3; Button b1,b2; String key; int ok=0; /** Initialization method that will be called after the applet is loaded * into the browser. */ public void init() { t1=new TextField("设置密码:",10); t1.setEditable(false); t2=new TextField(10); t2.setEchoChar('*'); b1=new Button("确定"); b2=new Button("确定"); add(t1); add(t2); add(b1); b1.addActionListener(this); b2.addActionListener(this); add(t3); add(b2); // TODO start asynchronous download of heavy resources } public void actionPerformed(ActionEvent e) { if(e.getSource()==b1) { key=t2.getText(); removeAll(); //从小程序中移去所有组件 t1.setText("请输入你的密码:"); add(t1); add(t3); add(b2); } else if(e.getSource()==b2) { removeAll(); if(key.equals(t3.getText())) { ok=1; repaint(); } } } public void paint(Graphics g) { if(ok==1) { g.setColor(Color.red); g.drawString("我是张同虎", 60, 50); } } // TODO overwrite start(), stop() and destroy() methods}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -