0

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.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by JellyTurf
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.