/*
 *
 */

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

/**
 *
 */

public class FaultyAnimation {
    
  /**
   * entry point, create an instance and pass on to createAndShowGUI()
   */
  public static void main (String[] args) {
    final FaultyAnimation p = new FaultyAnimation();
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
	  public void run() {
	    p.createAndShowGUI();
	  }
	});
  }


  private JFrame _frame;

  /**
   * sets up everything, and then makes Frame visible
   */
  public void createAndShowGUI() {
      //Create and set up the window.
    _frame = new JFrame("FaultyAnimation") {
	  public void paint(Graphics g) {
	    g.setColor(Color.BLUE);
	    int x = 200;
	    int y = 0;
	    int radius = 20;
	    for(int i = 0; i < 400; i++) {
	      g.clearRect(0,0,400,400);
	      y++;
	      g.fillOval(x-radius,y-radius,2*radius,2*radius);
	      System.err.println("x " + x + " y " + y + " r " + radius);
	      synchronized (this) {
		try {
		  wait(10);
		} catch (InterruptedException e) {
		  System.err.println("waiting interrupted ???\n\n" + e);
		}
	      }
	    }
	  }
	};
    _frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    _frame.setPreferredSize(new Dimension(400,400));
    _frame.pack();
    _frame.setVisible(true);
  }
}	
