import java.applet.Applet;
import java.awt.*;
public class App01 extends Applet implements Runnable
      {
      Thread oval;                       // Thread needed to begin animation.
      int left , width , top, height,timer;
	public void init( )   //Like a constructor - initialize variables
	{
        	left = 300;
		width = 100;
		top = 200;
		height = 50;
		timer = 100;
   	}
      public void start( ) 
	{
		oval = new Thread(this);
		oval.start();
	}
	public void run( ) 
	{
	while (true)      //infinite Loop ends when browser is closed or navigated
          {		// to another page.
	        repaint();
	        left = (int)(Math.random() * 600 );
	        top = (int)(Math.random() * 400 );
	        width = (int)(Math.random() * 300 )+50;
	        height = (int)(Math.random() * 300 )+50;
    	        timer ++;
	        try            //  Thread throws and exception so try is needed here.
	    		{
	    			Thread.sleep(200);   
	    		}
	        catch (Exception e) {} //	 Just squelch the exception here	
	      } 
	}
	public void paint(Graphics pen) 
	{
		pen.setColor(Color.black);
		pen.drawString("7 left " + left + " Top " +top + 
			" loop counter " + timer, 50, 60 );
		Color circleColor = new Color((int)(Math.random() * 256),  // red
					               (int)(Math.random() * 256),  // green
									(int)(Math.random() * 256)); // blue	     
		pen.drawLine((int)(Math.random() * 400),         // x  end point
		             (int)(Math.random() * 300),                   // y  end point
		             (int)(Math.random() * 400) + 400,         // x  second end point
		             (int)(Math.random() * 300) + 300);        // y  second end point 
		
	}
}

