import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class ExpandingRing extends Applet implements MouseListener { private int x = 100, y = 100; // Coordinates of the mouse click private int pauseLength; // Speed control from HTML tag public void init() { pauseLength = Integer.parseInt(getParameter("PauseLength")); setBackground(Color.white); addMouseListener(this); } public void paint(Graphics g) { int count = 0; while (count < 100) { int radius = 5*count; int diameter = 2*radius; g.setColor(Color.black); g.drawOval(x-radius, y-radius, diameter, diameter); // Draw pause(pauseLength); g.setColor(Color.white); g.drawOval(x-radius, y-radius, diameter, diameter); // Erase! count = count+1; } } private void pause(int howLong) { for (int count = 0; count < howLong; count++); } public void mouseClicked(MouseEvent e) { x = e.getX(); y = e.getY(); repaint(); } public void mouseExited(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }