aspose file tools*
The moose likes Applets and the fly likes multiple animations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "multiple animations" Watch "multiple animations" New topic
Author

multiple animations

Mike Petrovich
Greenhorn

Joined: Jun 15, 2012
Posts: 3
I have two animations, each of which works fine when it's the only applet in the web page. I would like to have them in the same web page, but when I do, if one is scrolled off screen, the one that remains on screen stops updating, unless it is forced to (by scrolling again, for instance). I am afraid there's something really important about threads that I do not understand, since I can't understand why I have this problem. I would appreciate your advice.

Additional information, if it's helpful: the problem occurs in both Firefox and IE; both animations update as long they're both at least partially on screen; I know the threads are still running, even though updating stops, because when I do force an update, the time variable has advanced; if I put a debug statement in either the paint or the update methods, such as System.out.println("painting"), the problem fails to occur.

Here's the skeleton of the applets:

Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4522
    
    5

I recommend you change over to Swing JApplet (AWT has been superseded by Swing more than 10 years ago!) and use javax.swing.Timer, not Thread#sleep(...).

If you have a valid reason to stick with AWT (hint: you don't) the use java.util.Timer.


luck, db
There are no new questions, but there may be new answers.
Mike Petrovich
Greenhorn

Joined: Jun 15, 2012
Posts: 3
OK, thanks for the suggestions. I have figured out that the problem lies in the javascript that calls the applets, so my java code is okay.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multiple animations
 
Similar Threads
back_buffer ?
Need help with synchrnoized/wait/notify mechanism!
for loop in paint method........
Having Problems with Multithreading Two Animations
Webcam & Threads