You can, but it's a little more involved... What you can do is use a BufferedImage for the background image and getGraphics() from it to get a Graphics reference. You then use that Graphics reference to draw to the image. Then in another Graphics object (from another image or a component) you can do a drawImage() to "paste" the original BufferedImage into the background. Then you can draw on top of the previous image using the current Graphics object.

I don't see anything currently that would cause the reduced graphics quality... the scaling of the images that are commented out in the print() method could have caused that though.

It could be that printing is handled stuff differently, too. It's the difference between vector and raster images... vector images are basically instructions on how to reproduce the image. The image can be scaled with no loss of detail or other artifacts, and printers can handle this well. Raster images are basically just a collection of colored pixels, and artifacts will appear if they are scaled. Not sure if the Java implementation of printing components uses a vector way of printing components normally, but using the BufferedImage would change the image to be a raster image. This also might be a cause, but I'd have to do some digging to see how components handle printing to see if the vector/raster thing is true.

Rich Stepanski
Ranch Hand

Joined: Aug 24, 2004
Posts: 59

posted Dec 23, 2004 09:58:00

0

I'll look into it also.

I was originally printing from the displayPane object - and passing the graphics object in its print() right to paint(). The graphics in print() refers to the actual printing graphics. That had the highest quality - if that helps any. Thanks though.