File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes animation using threads dilemma Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "animation using threads dilemma" Watch "animation using threads dilemma" New topic
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: 37985
    
  22
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: 37985
    
  22
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: 19651
    
  18

If there no longer is an edit button then no, you cannot edit that post anymore.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: animation using threads dilemma
 
Similar Threads
bouncing ball
Start: applet not initialized
YoYo goes up and down on a string but the yoyo doll doesn't display it appears broken in Internet Ex
Start: Applet not initialized