problem with transparency

What i need to do is to draw from a graphics object straight onto a buffered image.

this buffered image must only show what is drawn from the graphics eg a line or circle etc, and everything else has to be transparent.

i have tried this:

int w = this.getWidth();

int h = this.getHeight();

layer =new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);

Graphics2D g2 = layer.createGraphics();

this.paint(g2);

g2.dispose();

but instead of making a transparent image it makes a kind of gray color (its not the background of a JComponent showing through because i set its background to white).

can anyone help?

thanks

[784 byte] By [boblettoj99a] at [2007-11-27 7:43:12]
# 1
You should be able to create a new Color object with 1.0 alpha value, and fillRect over the whole thing with that color, then draw your image on top of it.
hunter9000a at 2007-7-12 19:24:00 > top of Java-index,Java Essentials,New To Java...