i need a simple way to slow down a for loop using a simple timer-like method. i know for a fact that there is one, because i used it in high school, i just can't remember the code.

Thread.sleep(<time>)

Thread.sleep(<time>)

how would i use this in this:

import java.applet.*;
import java.awt.*;


public class draw extends Applet
{
	
	public void paint(Graphics g)
	{
		//Timer delay = new Timer()
		
		for(int i = 0;  i < 255;  i++)
		{
			Color myRed = new Color(i, 0, 0);
			g.setColor(myRed);
			g.fillRect(0,i,100,3);
		}
	
		
		for(int t = 0;  t < 255;  t++)
		{
			Color myGreen = new Color(0, t, 0);
			g.setColor(myGreen);
			g.drawRect(100,t,100,3);
		}
		
		
		for(int q= 0;  q < 255;  q++)
		{
			Color myBlue = new Color(0, 0, q);
			g.setColor(myBlue);
			g.fillRect(200,q,100,3);
		}
		
		
		
	}
	
}

i just want the output to show the animation actually happen instead of instantly print the boxes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.