防止 Swing 剪切完全被半透明 JComponent 覆盖的 JComponent
我正在处理一个项目,要求我能够在同一容器内的组件顶部绘制半透明的 JPanel。使用 setComponentZOrder() 方法对于重叠(即下方的组件未完全覆盖)效果很好,但当下方的组件完全覆盖时会对其进行剪辑。
TLDR;
1)我在同一个容器中有两个 JPanel,两者都有不同的背景颜色
2) 一个的 ZIndex 为 0(称为 A),另一个为 1(称为 B)
3) B 透明度为 50%
3)当B与A的一部分重叠时,一切都会按预期进行
4) 当 B 完全覆盖 A 时,A 被剪裁,我们看到的只是 B
有什么想法可以解决这个问题吗?感谢您的帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
具有透明度的背景应该解释正在发生的事情并提供一些信息关于如何解决问题的建议。
如果您需要更多帮助,请发布您的 SSCCE 显示问题。
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.