The Java Program: List.java
1 import java.applet.Applet;
2 import java.applet.AppletContext;
3 import java.awt.*;
4 import java.util.Enumeration;
5
6 public class List extends Applet {
7 public void paint (Graphics g) {
8 final FontMetrics fm = g.getFontMetrics();
9 int y = fm.getAscent() + 20;
10
11 for (Enumeration e=getAppletContext().getApplets(); e.hasMoreElements(); ) {
12 final Applet a = (Applet) e.nextElement();
13 if (a == null) {
14 continue;
15 } else if (a==this) {
16 g.setColor (Color.red);
17 } else {
18 g.setColor (Color.black);
19 }
20 if (a.getParameter("name") != null) {
21 g.drawString (a.getParameter ("name"), 2, y);
22 } else {
23 g.drawString ("no name", 2, y);
24 }
25 y += fm.getHeight();
26 }
27 }
28 }
29