home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java by Example
/
jbecd.bin
/
JBE-CD
/
NTUsers
/
JBECODE.ZIP
/
JavaByExample
/
chap10
/
Applet8.java
< prev
next >
Wrap
Text File
|
1996-02-06
|
1KB
|
44 lines
import java.awt.*;
import java.applet.*;
public class Applet8 extends Applet
{
TextField textField1;
TextField textField2;
public void init()
{
textField1 = new TextField(5);
textField2 = new TextField(5);
add(textField1);
add(textField2);
textField1.setText("1");
textField2.setText("10");
}
public void paint(Graphics g)
{
g.drawString("Enter start and end values above.", 50, 45);
String s = textField1.getText();
int start = Integer.parseInt(s);
s = textField2.getText();
int end = Integer.parseInt(s);
int row = 0;
int count = start;
while (count <= end)
{
s = "Count = ";
s += String.valueOf(count++);
g.drawString(s, 80, row * 15 + 70);
++row;
}
}
public boolean action(Event event, Object arg)
{
repaint();
return true;
}
}