permaculture playing cards
The moose likes Java in General and the fly likes Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Question" Watch "Question" New topic


George Hawmin

Joined: Feb 20, 2005
Posts: 3
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

Joined: Jul 08, 2003
Posts: 24199

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.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Question
jQuery in Action, 3rd edition