Question

I'm working a project that requires me to be able to draw a semi-transparent JPanel on top of components within the same container. Using the setComponentZOrder() method works well for overlaps (i.e., component underneath is not completely covered) but clips the component underneath when it is completely covered.

TLDR;
1) I have two JPanels within the same container, both with different bg colours
2) One has a ZIndex of 0 (call it A), the other of 1 (call it B)
3) B has 50% transparency
3) When B overlaps part of A, everything works as expected
4) When B completely covers A, A gets clipped and all we see is B

Any ideas on how to fix this? Thank you for your help!

Was it helpful?

Solution

Backgrounds With Transparency should explain whats happening and provide a couple of suggestions on how to solve the problem.

If you need more help then post your SSCCE showing the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top