Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multiple animations

 
Mike Petrovich
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mike Petrovich
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic