This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I'm double buffering to reduce screen flicker which basically means that instead of calling repaint(), I'm drawing directly to an Image object and then call JPanel.getGraphics().drawImage(masterImage); to refresh the display. I would like to make use of Swing's GUI widgets, like JCheckBox. Is there a way I can extract a widgets display as an Image so I can just throw it into my master image using it's Graphics.drawImage() method?
When you break the big rules, you get a lot of little rules.
The Swing widgets themselves are double buffered. My display has a bunch of custom graphics and some animation, which causes a lot of screen flicker when animating. That's why I'm drawing all my stuff to a single Image object and sending it to the screen just once.
Now, you are right in that even if I did extract the widget's image and threw it onto this Image object, I would not be able to use it since the actual widget would be underneath this Image object I'm throwing up. Is it possible for me to tell the JCheckBox to always remain on top when I add it to the JPanel so when I throw this Image up it will be under the JCheckBox? Thanks.