Hi, I was wondering if it was possible to get an Image/BufferedImage, on to a JPanel, similar to when you do...
I know I can simply do a drawImage(...) inside the paintComponent(...) method, but I am having to repaint the screen many times with several small images, and I wanted to do it so the background does not have to be continuously repainted.
No matter what you do - the background is going to be continuously repainted... all that setBackground(Color background) does is set some variable in the JComponent superclass that gets used in JComponent.paintComponent() as:
If you're worried about re-doing stuff in the paint method that you don't need to re-do every time (like scaling, rotating, modifying an image, string, geometric shape, etc.) then you can create a BufferedImage, paint to the BufferedImage's Graphics, and then inside your paintComponent() method, just paint the BufferedImage only.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Apr 11, 2005
Thanks, thats kind of the same thing I was trying today, double buffering I think its called.
I'm using double buffering (painting to an Image, then displaying image), but I'm still getting a little bit of black flickering that can be seen when the cube is twisted(by pulling on a non-center face), the black flickering can usually be seen where two small faces join, whilst being twisted.
I have found, that on a Mac computer this flickering is really bad, but hardly noticeable when using windows. I assumed double buffering would fix this, but it hasn't, any ideas?
Thanks [ April 03, 2007: Message edited by: colin shuker ]