You do not need to use XOR at all. Especially if you have the two layers separated, it's much easier than that.
// Opaque
private Composite paintMode = AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f);
// transparent; erases the foreground image allowing the background image through
private Composite eraseMode = AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f);
Then when it comes time to draw:
if (drawing) {
graphics.setComposite(paintMode);
}
else {
graphics.setComposite(eraseMode);
}
Then paint like normal. I have a full source code example I can share if you'd like.
I82Much
2010-08-05 02:58:28