import java.awt.*; import java.applet.Applet; // This appears in Core Web Programming from // Prentice Hall Publishers, and may be freely used // or adapted. 1997 Marty Hall, hall@apl.jhu.edu. /** Position circles down the diagonal so that * their borders just touch. Illustrates that * Java 1.1 lightweight components can be * partially transparent. * @see BetterCircle */ public class BetterCircleTest2 extends Applet { public void init() { setBackground(Color.lightGray); setLayout(null); BetterCircle circle; int radius = getSize().width/6; int deltaX = round(2.0 * (double)radius / Math.sqrt(2.0)); for (int x=radius; x<6*radius; x=x+deltaX) { circle = new BetterCircle(Color.black, radius); add(circle); circle.setCenter(x, x); } } private int round(double num) { return((int)Math.round(num)); } }