home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-02-26 | 828 b | 40 lines |
- import java.awt.*;
- import java.applet.*;
-
- public class EchoApplet extends Applet
- {
- TextField textField;
- Button button;
-
- public void init()
- {
- textField = new TextField("", 25);
- button = new Button("Change Echo");
-
- textField.setEchoCharacter('*');
-
- add(textField);
- add(button);
- }
-
- public boolean action(Event evt, Object arg)
- {
- if (evt.target instanceof Button)
- ChangeEcho();
-
- return true;
- }
-
- protected void ChangeEcho()
- {
- char c = textField.getEchoChar();
-
- if (c == '*')
- textField.setEchoCharacter('#');
- else if (c == '#')
- textField.setEchoCharacter('$');
- else
- textField.setEchoCharacter('*');
- }
- }
-