home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java by Example
/
jbecd.bin
/
JBE-CD
/
NTUsers
/
JBECODE.ZIP
/
JavaByExample
/
chap06
/
NameApplet.java
< prev
Wrap
Text File
|
1996-01-31
|
746b
|
33 lines
import java.awt.*;
import java.applet.*;
public class NameApplet extends Applet
{
TextField textField1;
TextField textField2;
public void init()
{
textField1 = new TextField(20);
textField2 = new TextField(20);
add(textField1);
add(textField2);
}
public void paint(Graphics g)
{
g.drawString("Type your name and age above.", 25, 75);
g.drawString("Your responses are:", 40, 100);
String s = textField1.getText();
g.drawString(s, 40, 120);
s = textField2.getText();
g.drawString(s, 40, 140);
}
public boolean action(Event event, Object arg)
{
repaint();
return true;
}
}