import java.applet.*;
import java.awt.*;
public class PoetryApplet extends Applet {
String[] poem = new String[101];
int numlines;
public void init() {
String nextline;
for (numlines = 1; numlines < poem.length; numlines++) {
nextline = this.getParameter("Line" + numlines);
if (nextline == null) break;
poem[numlines] = nextline;
}
numlines--;
}
public void paint(Graphics g) {
int y = 15;
for (int i=1; i <= numlines; i++) {
g.drawString(poem[i], 5, y);
y += 15;
}
}
}
Here's the applet:
You might think it would be useful to be able to process an arbitrary list of parameters without knowing their names in advance, if nothing else so you could return an error message to the page designer. Unfortunately there's no way to do it in Java 1.0 or 1.1. It may appear in future versions.