Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

animation using threads dilemma

 
Vonique Leary
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Pie
Posts: 50246
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I will do that. Thank you, Campbell!

Vonique
 
Campbell Ritchie
Sheriff
Pie
Posts: 50246
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome

I hope it works
 
Vonique Leary
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there no longer is an edit button then no, you cannot edit that post anymore.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic