import java.awt.*; // A variation of a class that appears in Core Web // Programming from Prentice Hall. May be freely used // or adapted. // 1998 Marty Hall, http://www.apl.jhu.edu/~hall/java/ /** A Circle component built using a Canvas. */ public class Circle extends Canvas { public Circle(Color foreground, int radius) { setForeground(foreground); setSize(2*radius, 2*radius); } public void paint(Graphics g) { g.fillOval(0, 0, getSize().width, getSize().height); } public void setCenter(int x, int y) { setLocation(x - getSize().width/2, y - getSize().height/2); } }