import java.awt.*;
import java.awt.image.*;
import java.util.*;
import java.net.URL;
import java.io.IOException;
public class CodeFace extends java.applet.Applet {
...
public void paint(Graphics g) {
int x = 0, y = 0;
for (int i = 0; i < faces.length; i++) {
g.drawImage(faces[i], x, y, this);
g.drawString(names[i], x, y + faces[i].getHeight(this) + 20);
x += faces[i].getWidth(this);
}
}
public static void main(String[] args) throws IOException {
Frame f = new Frame("CodeFace");
f.add(new CodeFace());
f.setSize(350, 170);
f.show();
}
}
|