draw transparent component on bufferedimage?

A

aksel.schmidt

i have a component living in the glasspane, partly transparent to
allow see through to the background

now i want to take a 'snapshot' of the transparent component to make
som animations in the glasspane with (slide transition etc.) - but i
cannot make the transparency information appear on the buffered image
- i use:

public static BufferedImage createImage(JComponent component) {
Dimension d = component.getSize();
if (d.width == 0) {
d = component.getPreferredSize();
component.setSize(d);
}

GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();

BufferedImage image = gc.createCompatibleImage(d.width,
d.height, Transparency.TRANSLUCENT);
Graphics2D g2d = image.createGraphics();
component.paint(g2d);
g2d.dispose();
return image;
}

how do i paint a transparent component on an image?

thanks!

Aksel,
denmark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top