what im having trouble with is making an applet which has animates like the matrix code.. lines come down at random positions etc.. my lecturer said that it only takes 20 lines of code and is very simple.

he gave us this info as a hint:

Use the random class! 
 
example 
Random r = new Random(); 
for(….) 
{ 
posX = r.nextInt(300); 
posY = r.nextInt(300); 
}

this is what i have come up with so far but i don't get how to animate it :S

int rad = 25;
			int x = 25;
			
			Random r = new Random();
			
			
			for(int j =1; j<100;j++)
			{
				Color  c = new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256));
				g.setColor(c);
				g.fillOval(r.nextInt(200),r.nextInt(200), rad*2, rad*2); 
				
			}

im just testing with circles, to make them show up randomly.. this works but they are stationary, i don't get how to make them moving in less than 20 lines of code, in our lecture notes there is no info on animation.

any help will b appreciated :)

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.