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 885781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:57:51+00:00 2026-05-15T12:57:51+00:00

I have a custom UI drawn for my java application. Right now I draw

  • 0

I have a custom UI drawn for my java application. Right now I draw the entire UI from scratch. I know for a fact some parts of the UI are static. I know I could save these static parts to an image, but will this yield a improvement in performance (Since even an image must be drawn every frame)?

Is it plausible to save a reference to the Graphics2D object after the UI has been drawn and assign that to the new graphics object every frame (starting from a point where all the static components are drawn)?

Thanks in advance,
Alan

  • 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-05-15T12:57:52+00:00Added an answer on May 15, 2026 at 12:57 pm

    You don’t need to redraw everything in every frame. So if you have static parts of your UI (or even dynamic parts that you know haven’t changed since last frame) then you simply don’t need to repaint them.

    In my code (Swing games and simulations mostly) I usually try to follow the following rules:

    1. Pre-prepare static images (e.g. BufferedImage textures for UI elements)
    2. Override the paintComponent() method for each UI element individually to do the painting
    3. Only call the repaint() method of any given UI element if I know that something has changed
    4. Call repaint() in a timer-based loop for animation, but only call it on the portion of the UI that is being animated (e.g. a nested JPanel)

    This approach seems to work and perform pretty well (though I’d welcome comments if there are ways to improve it!!)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom Widget derived from QFrame. I will need to draw on
I have a custom view extending from View with lots of text drawn at
I have written a new custom component derived from TLabel. The component adds some
In the following example, I have a custom JComponent being drawn on green background,
I have a custom view which has a piano keyboard drawn inside of it.
I have a custom UIView that contains an interactive drawing that is drawn in
I'm using a custom JLayeredPane. I have several Shapes which needed to be drawn
I have a JPanel that implements custom drawing to draw a background. Over this,
I have a problem making an inner class that extends from JPanel to draw
I have a drawing application in Android that allows the user to draw with

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.