Reputation: 151
I'm developing a java application for draw through the drag of the mouse.
I need the JPanel
to be transparent, but in this way lose the function rubber.
With the getBackground()
can set the transparent color to use, but the path is not going to erase what was previously drawn.
Upvotes: 0
Views: 74
Reputation: 6618
Drawing with transparent means... drawing with transparent, so the previous color stays intact. What you want is clearing a part of the image (you're drawing on an image surface, right?). That can be done using the clearing rule of AlphaComposite.
// Assuming Graphics2D g, maybe from BufferedImage
g.setComposite(AlphaComposite.Clear);
// drawing now clears
Upvotes: 1