Help -- Thread basics

I know what Thread's about along side Runnable.

But how do I actually use it?

e.g. I have a panel with a mouseClicked listener, and I want to draw an animation on its Graphics [ not a "gif", but do a series of actions, like in paint(Graphics g) ] each time I click my mouse, so that even if I click my mouse with small spaces of time between each click, every animation will be drawn till its end.

Help please :)

[438 byte] By [Severus_a] at [2007-10-2 6:10:26]
# 1
Have a look at the Timer class (the one in the javax.swing package,not the java.util.Timer class). It invokes tasks at regular intervals in theAWT event thread; exactly what you want.kind regards,Jos
JosAHa at 2007-7-16 13:11:05 > top of Java-index,Java Essentials,Java Programming...
# 2

Thanks.

I tried using that, and it doesn't work... well -- it works as a Timer object but I still can't do what I needed, so I'll just give the files here.

I want to generate, in the following panel, circles around the mouse when it's clicked. That's all, but for some reason it won't work.

I also tried to create a new class that extends Thread or implements Runnable but I couldn't get the repaint action to constantly repaint the panel and make the circles visible.

I just started this, so the panel code only has setPreferredSize, the mouse listener for the clicks and an empty paint(Graphics g) method.

Please, help :D

Severus_a at 2007-7-16 13:11:05 > top of Java-index,Java Essentials,Java Programming...