I have this program that I have written a month or so ago and I want to make the applet animate the plotted points. Basically show the shapes being drawn in real time instead coming up already done.

Is there a way to make them change colors randomly?

I also, want to make it loop drawing random things everywhere any suggestions?

I was trying to use the timer, but I really dont understand how to use it.

thanks




Code:
import java.applet.*;
import java.awt.*;
import java.lang.Math;
import java.awt.Point;
import java.awt.Graphics;
import java.io.*;
//import java.io.Serializable;
import javax.swing.Timer;

public class DDASimple extends Applet
{

Timer timer;
int pause;
int speed;
    
    public void init()
    {
    }
    
    public void paint(Graphics g)
    {


//Set up timer to drive animation events.
        timer = new Timer(speed, this);
        timer.setInitialDelay(pause);
        timer.start(); 

	g.setColor(Color.WHITE);
	//g.fillRect(0, 0, getWidth() - 1, getHeight() - 1);
	g.setColor(Color.BLACK);
	
	DDASMPL(160, 140,  220,  140, g);
	DDASMPL(100, 100,  160,  140, g);
	
    }
    
    public void DDASMPL(int x1, int y1, int x2, int y2, Graphics g)
    {
	
	int   dx, dy, steps, k, jim;
	float xinc, yinc, x, y;
	
	
	dx = (x2-x1);
	dy = (y2-y1);
	
	
	if( Math.abs(dx) > Math.abs(dy))
	    
	    steps = Math.abs(dx);
	else
	    
	    steps = Math.abs(dy);
	
	
	//I need to typecast so I dont lose my float values
	 xinc = (float) dx / (float)steps;
	 yinc = (float) dy / (float)steps;
	
	x = x1;
	y = y1;
	
        //plotting the point for x1, and y1 
	g.fillRect(x1, y1, 1, 1);
	
	for (k = 1; k <= steps; k++)
	    {
		x = x + xinc;
		y = y + yinc;
		
                //plotting the points to the screen
		g.fillRect(Math.round(x), Math.round(y),1 ,1);
	    }
	
    }//end function dda
    
}//end class ddda applet