@Override
public void paint(Graphics gr) {
if (transparent) {
Rectangle r = gr.getClipBounds();
final int w = r.width;
final int h = r.height;
if (getWidth() > 0 && getHeight() > 0) {
final BufferedImage buf =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
Graphics2D g = buf.createGraphics();
g.setComposite(AlphaComposite.Clear);
g.fillRect(0, 0, w, h);
g.dispose();
g = buf.createGraphics();
g.translate(-r.x, -r.y);
super.paint(g);
g.dispose();
paintDirect(buf, r);
}
}
else {
super.paint(gr);
}
}
/** Use the contents of the given BufferedImage to paint directly