PAULUS
PAULUS

Reputation: 222

Java Swing Double Buffer Problems

When overriding the paintComponent method of a Swing component and having the graphics object NOT draw over the entire surface of the component (for example, just a g2.rotate(0.3) will show you both the painted and non-painted portions), the non-painted portions of the component are being filled garbage colors from the back-buffer image.

If I disable double buffering from the RepaintManager, the garbage does not appear and the non-painted portions show as transparent, but everything looks like crap because of all the repainting and no buffering.

Even I use the g2 object in paintComponent to set the alpha to 50%, I can still see the buffered garbage through the transparency.

I've tried disabling double buffering on a single component, but no dice there either.

This problem is documented other places, like here: http://www.java.net/node/689238

...but there doesn't seem to be a way to correct this buffer corruption...Anyone have any ideas?

Also, on a Windows system, changing the theme to "Classic" will fix this problem...Maybe it's an OS problem?

Thanks!

Upvotes: 0

Views: 570

Answers (2)

PAULUS
PAULUS

Reputation: 222

This seems to be a problem related Windows Aero themes and how Windows handles its own transparencies. Classic or Basic themes (or a non-windows OS) corrects this. Thanks for the help.

-Paul

Upvotes: 0

Joop Eggen
Joop Eggen

Reputation: 109547

Did you do setOpaque(false)?

Upvotes: 1

Related Questions