This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Question" Watch "Question" New topic
Author

Question

George Hawmin
Greenhorn

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
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question
 
Similar Threads
[ExamLab] - What does it matter with this question? Has it problem?
telling jlabel ignore application repaint
Mock exam questions
How do I tell the content pane to stop repainting in this case?
Cant get JButton to appear in the game