954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Page flipping, howto?

So I have a component that renders very slowly. The problem is that I can only render inside the event handling thready, which shouldn't be freezed.
Long ago in pascal/assembly I used backbuffer and page flipping. I've read that Java supports double buffering, but no info about thread safety.
So the question is, how can I render in a worker thread, and then show it in the event handling one?
Thanks!

MoZo1
Junior Poster
119 posts since Mar 2008
Reputation Points: 43
Solved Threads: 4
 

You can create a new Image object in the worker thread, get its Graphics, and draw your page to it. Then in the paintComponent swing thread you just need to draw that Image to the Swing Graphics. Google "Java off-screen rendering" for examples and discussions

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: