| Author |
animation using threads dilemma
|
Vonique Leary
Ranch Hand
Joined: Mar 24, 2008
Posts: 107
|
|
Hello,
I've been tasked with animating this stick figure using a yoyo. I have been able to do that with the above code, but my problem is that the yoyos need to be going up and down at different rates. I know I need to add another thread but what is confounding me is that since I cannot write two paint methods in one applet, how will I distinguish which yoyo and string is going at which rate? How can I split up the paint method so that one part goes in one thread and another part is going in another thread and each thread's yoyos are going at different rates? Or am I totally going off the deep end???
Any help or suggestions would be appreciated, as I'm thoroughly confused.
Also, why is it that Runnable has to be implemented in order to use the run method? Why can't we just create our own run method and forget Runnable?
Thanks,
Vonique
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32652
|
|
The reason you have to implement Runnable is that the parameter type of the methods calling it is Runnable.
Have you tried the Timer class in the Swing package? Note the links from that API page.
I think this thread is a candidate for moving to the Swing forum.
|
 |
Vonique Leary
Ranch Hand
Joined: Mar 24, 2008
Posts: 107
|
|
Okay, I will do that. Thank you, Campbell!
Vonique
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32652
|
|
You're welcome
I hope it works
|
 |
Vonique Leary
Ranch Hand
Joined: Mar 24, 2008
Posts: 107
|
|
|
Is there a way to edit this post? I only meant to post my code and my questions, not Campbell's reply. Thanks, Vonique
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
If there no longer is an edit button then no, you cannot edit that post anymore.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: animation using threads dilemma
|
|
|