import java.awt.*; import java.awt.event.*; import java.util.Vector; // 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 frame that draws a small circle where you click.*/ public class DrawCircles extends CloseableAppletFrame { private Vector circles; /** When you click the mouse, create a SimpleCircle, * put it in the Vector, and tell the system * to repaint (which calls update, which clears * the screen and calls paint). */ private class CircleDrawer extends MouseAdapter { public void mousePressed(MouseEvent event) { circles.addElement(new SimpleCircle(event.getX(), event.getY(), 9)); repaint(); } } public DrawCircles() { super("Drawing Circles" ); circles = new Vector(); addMouseListener(new CircleDrawer()); setBackground(Color.white); setSize(500, 300); setVisible(true); } /** This loops down the available SimpleCircle objects, * drawing each one. */ public void paint(Graphics g) { SimpleCircle circle; for(int i=0; i