|
Hello, I have a panel whose paintComponent() paints a BufferedImage and
draws some lines and circles on top of the image. This panel also has several small TRANSPARENT child panels. The
transparent child panels hold labels, etc and the image and what’s drawn
on it can be seen under/through the transparent children. For the basic image itself, I apply a translation transform to center
the image. For drawing on top of the image, I restore the original transform so
that the drawing on top of the image is done with the identity transform. So my paintComponent method looks something
like this: protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; AffineTransform origAtx = g2.getTransform( ); g2.transform(centeringTransform); g2.drawImage(baseImage,
0, 0, this); g2.setTransform(origAtx); // do some drawing on top of the buffered image … } My problem is this: I get drawing artifacts within my transparent child panels. For
example, a circle is drawn over the image in the main panel and part of the
circle (an arc) is reproduced inside of one of my child panels. Seems to me that each time Swing needs to refresh the background of one
of the transparent children, it calls paintComponent() to get the proper background. However, it is not getting
the correct part of the underlying image to use as its background. Has anyone else seen anything similar? I’m using JDK 1.3.1 Thanks, Ted Hill |
