import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Rings 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")); addMouseListener(this); } public void paint(Graphics g) { int count = 0; while (count < 100) { int radius = 5*count; int diameter = 2*radius; g.drawOval(x-radius, y-radius, diameter, diameter); pause(pauseLength); // To slow the drawing down to see the loop order 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) { } }