Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7941033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:32:34+00:00 2026-06-03T23:32:34+00:00

I want to do animation in Java. I have looked at: http://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html What I’m

  • 0

I want to do animation in Java. I have looked at: http://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html

What I’m surprised by is that in the timer action handler:

  • we do NOT do actually drawing function calls; we just update the state — so it appears the timer action is used for “simulation”
  • we do a repaint request
  • Swing repaints its request at its convenience

This seems somewhat odd to me because:

  • Swing can collate multiple repaint requests into one
  • if I’m counting fps in the timer, I can be over counting (since multiple repaints becomes one)

Question: am I mis reading the sample code, or is this the “correct” way to do animation in Java?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:32:36+00:00Added an answer on June 3, 2026 at 11:32 pm

    It’s fairly normal to do the state updates and rendering separately.

    Java/Swing is pretty normal in this regard.

    Reasons:

    • Lots of things can update the state (timer events, user input etc.) so it’s useful to make changes very lightweight and decouple them from screen refreshes so that you can do them at any time
    • You often want screen refreshes to run at a different rate from the model state updates. Typically you want a fixed interval for animation / state updates but want the screen refreshes to happen as fast as they can. This is especially true if you are doing interpolation in your animations.
    • Rendering often needs to take place in a specific context (in this case, the Swing UI thread). You don’t necessaily want to limit state changes to also only happen in this context
    • It’s good practice to separate view (screen presentation) from the data model. Apart from being a good conceptual design distinction, this allows you do things like test the data model independently from the display, run a version of the model on a server without a GUI etc.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have followed this tutorial ( http://stuffthathappens.com/blog/2008/11/13/android-animation-101/ ) and have a beautiful rotating text
I have a simple animation the problem is I want the animation to end
i want create image animation , i have 50 images with png format now
I have a problem with moving animation. I want to create animation which start
I have a problem with switching images in android. I want to create animation
I have a very simple animation task for Java. I need to create a
I want to play an animation(Gif) or a movie instead of Default.png. Is that
I want to create an animation effects which sort of shakes an image on
I want to display some kind of animation when my datagrid is updating. Does
I want to display a progress animation while updatepanel's work being done, but without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.