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.0 components are rectangular and opaque. * @see Circle */ public class CircleTest2 extends Applet { public void init() { setBackground(Color.lightGray); setLayout(null); Circle circle; int radius = size().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 Circle(Color.black, radius); add(circle); circle.setCenter(x, x); } } private int round(double num) { return((int)Math.round(num)); } }