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

  • Home
  • SEARCH
  • 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 7630061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:00:05+00:00 2026-05-31T06:00:05+00:00

I got a requirement of a Loading images in a JPanel components. Consider the

  • 0

I got a requirement of a Loading images in a JPanel components.
Consider the JPanel has 10 components and all those components needed to be set with a Background image.
So in the paint method I implemented the background image setting logic but that is very slow.

I wanted to achieve the same task but with efficient way.

  • 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-31T06:00:07+00:00Added an answer on May 31, 2026 at 6:00 am

    The Component’s paint method is invoked every time you move, drag, resize, … your window and in several other situations. Therefore only use the paint method for (re)painting your component and invoke the loading process only once.

    Create small thumbnails of your images, and cache them in some kind of class, for example:

    class Thumbnail extends Component {
       ...
       BufferedImage cachedThumbnail;
    
       public Thumbnail(File thumbnailFile) {
           //read image
           //(scale image)
           this.cachedThumbnail = ...;
       }
       ...
       public static void paint(Graphics2D g) {
         //only paint the cached image ...
         g.drawImage(cachedThumbnail,..,..,..,..);
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a requirement to create several shapes based on a supplied size (all
I got a requirement to write a log line when all wars have been
I have a folder with many images with different backgrounds. I have got requirement
Got a requirement to rebuild mssql full-text index. Problem is - I need to
I got the requirement like, In a page there will be 4 panels which
I've got a requirement where a user enters a few terms into a search
I have an existing application (with MySQL DB). I just got a new requirement
My requirement is to notify group of people if our backup fails. We've got
I've got a requirement to take some XML and transform it into a fixed-width
I have a requirement of loading assembly of different version(I already have the assembly

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.