Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question

 
George Hawmin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question. In an enviroment such as JPanel or Frame or FSEM mode(assuming that setIgnoreRepaint is false), how can you create an animation, with such as moving a picture, in both 2 ways:

1.With a specific timer (Thread.sleep() for example), and then auto-activates
2.With a certain input (keyboard prefered)

If you know how to animate without repaint() (setIgnoreRepaint(true)),
then I will also accept that.


Thank you.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The demo applets that come with the JDK are mostly animations, so if you simply need to see how you might create an animation, then those are as good a place to start as any.

But you seem to be asking something else -- how to start an animation based on some event? That of course depends on how you're doing the animation, but in general, just write code which, when the event occurs, creates and starts a Thread that runs the animation loop. If you need more details than that, then I think you'd have to ask a more specific question.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic