Monday, June 2, 2008

Creating a Swing Dashboard Widget - Part 6 (Flipping)

When the info button is pressed the widget should flip over to reveal the back.Using a flippable component to hold a blue front and green back, and hooking it up to the info button gives a very nice flipping transition, but with horrifying artifacts on OSX:

Also, on Windows the corners of the widget aren't transparent as expected:

After a little struggling I found that on Windows JPanels were causing the corner painting problem. Although marked as non-opaque their backgrounds were still being cleared to white every repaint! Turning off double buffering by passing false in the JPanel constructor fixed this:

Took a look and it's pretty cool but it controls the alpha value for the window *including all of its contents*.So using it would make the widget itself semi-transparent, not what we were looking for but actually a nice effect.I've fixed the OSX rendering problems separately. I'll post an update soon.