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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:22:48+00:00 2026-05-11T07:22:48+00:00

I’ve got a routine that paints an insanely large graph inside a scroll pane.

  • 0

I’ve got a routine that paints an insanely large graph inside a scroll pane. It’s too big to paint before adding to the scrollpane – the menory requirements would be several gigs.

Because of the size of the graph I’m rendering the chart within the paint method of the scrollpane’s child. Which works out well, however I’m noticing that every time a scrollbar is moved my paint routine is called twice – once with a clipping rect equal to the uncovered area scrolled to, and a second time with the clipping rect equal to the viewport’s dimensions.

For example if my viewport is 245×195 & I scroll down by 3 pixels my paint routine gets called with g.getClipBounds() set as follows:

java.awt.Rectangle[x=0,y=195,width=245,height=3] java.awt.Rectangle[x=0,y=3,width=245,height=195] 

… because I render within the paint routine this is causing flicker (I do my calcs as fast as I can, but there is a wee bit of a delay I guess). Questions:

  1. Does anyone know how to prevent the 2nd paint call? This is plain-jane JScrollPane stuff I’m doing here – I have a component, I add it to the scrollpane, I add the scrollpane to a parent component. You can see this behavior even in the first image scrolling demo @ the swing tutorial.

  2. If the answer to #1 is ‘nope’: can anyone think of a good way to deal with this ? Should I paint to some sort of image buffer, track recent paint calls & copy the image where possible ? I cannot imagine this being much faster than re-rendering, but any insight appreciated 🙂

  • 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. 2026-05-11T07:22:49+00:00Added an answer on May 11, 2026 at 7:22 am

    I’ve ran into this issue in the .NET world. Double buffering should solve your problem.

    If you’re rendering directly onto a surface that is shown on the screen, you have no control over when the ‘showing’ actually happens. What typically happens is: you start rendering, the not-yet-finished image is being displayed on the screen, you finish rendering, and then that is finally shown on the screen.

    If you begin your rendering logic by clearing to a background color, then this will appear like a flash. Double buffering prevents this because it’s always displaying from a completed render. The worst that could happen is slight ‘tearing’ but that’s only noticeable in quickly changing animations.

    Even if you only want to render part of a gigantic image, you can still use this technique. Simply render what you need onto an off-screen surface (which is the size of the visible portion you want). And then when you’re done, draw the entire image onto your display surface in one fell swoop.

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

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Do'h. My form fields weren't set. May 11, 2026 at 9:54 am
  • added an answer You could deconstruct it into 2 2D problems: Split the… May 11, 2026 at 9:54 am
  • added an answer For Eclipse 3.4 at least you can do the following:… May 11, 2026 at 9:54 am

Related Questions

I keep getting tasks that are above my skill level. How can I address this without coming accross as grossly incompetent?
I have a web-service that I will be deploying to dev, staging and production.
I'm thinking of starting a wiki, probably on a low cost LAMP hosting account.
I have the following tables in my database that have a many-to-many relationship, which
I'm using the RESTful authentication Rails plugin for an app I'm developing. I'm having
I recently printed out Jeff Atwood's Understanding The Hardware blog post and plan on
I find that getting Unicode support in my cross-platform apps a real pain in
I would like to test a string containing a path to a file for
I'm getting this problem: PHP Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable
I'm an Information Architect and JavaScript developer by trade nowadays, but recently I've been

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.