home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java by Example
/
jbecd.bin
/
JBE-CD
/
NTUsers
/
JBECODE.ZIP
/
JavaByExample
/
chap13
/
ScoreApplet.java
< prev
Wrap
Text File
|
1996-02-13
|
1KB
|
44 lines
import java.awt.*;
import java.applet.*;
public class ScoreApplet extends Applet
{
TextField textFieldScores[];
TextField textFieldNames[];
public void init()
{
textFieldScores = new TextField[3];
textFieldNames = new TextField[3];
for (int x=0; x<3; ++x)
{
textFieldNames[x] = new TextField(15);
textFieldScores[x] = new TextField(5);
add(textFieldNames[x]);
add(textFieldScores[x]);
textFieldNames[x].setText("Unknown");
textFieldScores[x].setText("0");
}
}
public void paint(Graphics g)
{
g.drawString("Your bowlers' averages are: ", 50, 125);
for (int x=0; x<3; ++x)
{
String s = textFieldNames[x].getText();
s += ": ";
s += textFieldScores[x].getText();
g.drawString(s, 75, 155 + x*15);
}
}
public boolean action(Event event, Object arg)
{
repaint();
return true;
}
}