home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java by Example
/
jbecd.bin
/
JBE-CD
/
NTUsers
/
JBECODE.ZIP
/
JavaByExample
/
chap13
/
Applet16.java
< prev
next >
Wrap
Text File
|
1996-02-13
|
1KB
|
42 lines
import java.awt.*;
import java.applet.*;
public class Applet16 extends Applet
{
TextField textField1, textField2, textField3;
int avg1, avg2, avg3;
public void init()
{
textField1 = new TextField(5);
textField2 = new TextField(5);
textField3 = new TextField(5);
add(textField1);
add(textField2);
add(textField3);
textField1.setText("0");
textField2.setText("0");
textField3.setText("0");
}
public void paint(Graphics g)
{
g.drawString("Your bowlers' averages are: ", 50, 80);
String s = textField1.getText();
g.drawString(s, 75, 110);
avg1 = Integer.parseInt(s);
s = textField2.getText();
g.drawString(s, 75, 125);
avg2 = Integer.parseInt(s);
s = textField3.getText();
g.drawString(s, 75, 140);
avg3 = Integer.parseInt(s);
}
public boolean action(Event event, Object arg)
{
repaint();
return true;
}
}