0

Hi , i was just wondering how you would produce a time delay in java. Bascically all im trying to do is draw a circle in a bunch of random places. Just draw circles way to fast. Here my code

import java.awt.*;
import hsa.Console;


public class Delay
{
static Console c;


public static void main (String[] args)
{
c = new Console ();
design();
}
static public void design () // randomly draws circles over HSA Console
{
int up = 0;
int x ;
int y;
int height;
int width ;
for (int counter = 0 ;; counter ++ ) // need to waste time between each
{                                   // for statement repetion
x = (int) (Math.random () * 500);
y = (int) (Math.random () * 500);
height = (int) (Math.random () * 100 );
width = (int) (Math.random () * 100 );
c.setColor (Color.red);
c.drawOval (x,y,height,width);
delay (10000);
}
}
public void delay (int howLong) // delay function to waste time
{
for (int i = 1 ; i <= howLong ; i++)
{
double garbage = Math.PI * Math.PI;
}
}
}

Edited by happygeek: fixed formatting

3
Contributors
3
Replies
8
Views
11 Years
Discussion Span
Last Post by tdizzle342
0

try
{
Thread.sleep(1000); // do nothing for 1000 miliseconds (1 second)
}
catch(InterruptedException e)
{
e.printStackTrace();
}

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.