java - 使imageicon具有透明背景 [英] java - making a imageicon have a transparent background

查看:476
本文介绍了java - 使imageicon具有透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码



this is my code

 URL url2 = new URL("http://frizfraz.com/skin-view/render.php?user=z3nox");
image2 = new ImageIcon(ImageIO.read(url2));
image2 = new ImageIcon(image2.getImage().getScaledInstance(150, 297, BufferedImage.SCALE_SMOOTH));
FrontImage = new JLabel(image2);
FrontImage.setHorizontalAlignment(SwingConstants.LEFT);
FrontImage.setVerticalAlignment(SwingConstants.TOP);
FrontImage.setBounds(10, 11, 151, 297);
contentPane.add(FrontImage);





代码很好,一旦我加载了网络上有透明背景的图像,我加载由于某种原因,它变成粉红色的程序,我不知道为什么,我希望它具有像在网络上的透明背景,有人可以帮助吗?并解释为什么它的粉红色和不透明,还有一个可以让我透明吗?



the code code is fine, once I load the image that has a transparent background on the web, and I load it onto the program it goes pink for some reason and i don't know why, I want it to have a transparent background like it had on the web, can some one please help? and explain why its pink and not transparent, and also, can some one help me make it transparent?

推荐答案

Darryl Burke相当整齐地解决了这个问题; http://tips4java.wordpress.com/2010/08/22/alpha-icons/ [ ^ ]



希望这会有所帮助,

Fredrik
Darryl Burke has solved this issue rather neatly; http://tips4java.wordpress.com/2010/08/22/alpha-icons/[^]

Hope this helps,
Fredrik


这篇关于java - 使imageicon具有透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆