Preventing Swing from clipping JComponents entirely covered by a semi-transparent JComponent

StackOverflow https://stackoverflow.com/questions/4080699

문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top