swing - java efficient repainting on moving objects -


i'm wondering what's efficient way of repainting in case, , how go it.

i've got jframe, containing jpanel. jpanel contains awt graphics. of these graphics fixed, don't move. other graphics (on top of fixed graphics) in panel move. layout updated every 3 seconds. fixed graphics require quite bit of math draw, don't want repaint graphics, moving ones.

this possibilities came with:

  1. to put fixed graphics , moving graphics in 2 separate panels , repaint 1 panel, layed on each other.
  2. to add 2 different graphics objects panel (one fixed graphics , 1 moving) , repaint 1 graphics object. (is possible?)
  3. perhaps other way don't know?

like others saying, use bufferedimage fixed object. moving objects, should calculate bounds of area needs redrawn (i.e. old bounding box union w/ new bounding box objects moved). blit fixed graphic section of area down first, , blit moved object(s).

you should double buffering if haven't already. better experience drawing offscreen buffer , flip screen when ready.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -