Java - JLabel 背景不是完全透明的?
我有一个 JLabel,上面有一个框图标。我在 Photoshop 中创建了图标的图像。这是一张 png-24 图像,背景已完全删除。
但是当移动到深色背景上时,您可以看到背景并不完全透明:
编辑 #2 :
图像是透明的。我什至浏览了 Photoshop 教程,以确保我以正确的方式创建透明图像。问题似乎出在 Java(和 JLabels)上。
如何解决这个问题?
I have a JLabel with a box icon on it. I create the icon's image in photoshop. It's a png-24 image with the background full erased.
But when moved on top of a dark background, you can see that the background isn't fully transparent:
EDIT #2:
The image IS transparent. I've even gone through photoshop tutorials to make sure I'm creating a transparent image the correct way. The problem seems to be with Java (and JLabels).
How do I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我测试过你的图像,它不透明。肯定就是这个原因。
@Gabe:将其粘贴到 html 文件中并将其加载到浏览器中。这显然不是任何与 java 相关的问题。
这是一个 Java 证明,证明您的图像不透明,并且正确的透明 PNG 可以正常工作。
i've tested your image, it is not transparent. surely that is the reason.
@Gabe: paste this into a html file and load it in a browser. This clearly isn't an issue with anything java related.
here's a java proof that your image isn't transparent AND that a proper transparent PNG works fine.
您可以尝试使用 GIF 格式并相应地设置 alpha 值。
我现在看不到你的图像。
好吧,请确保您创建的图像是透明的。
否则你将无法得到你所需要的。
制作透明图像的示例指南:LINK
You may try with GIF format and set alpha value accordingly.
I could not see your image right now.
Well, make sure image that you are creating that is transparent.
Otherwise you would not get it as you need.
sample guide for making transparent image: LINK