How do I handle transparent pixels in an ImageIcon
I was given a gif to use in a JButton. When I look at the gif with Paint,
the body of the gif is non-rectangular, but looks as if it were framed in a rectangle of black pixels. I assume that this "frame" is really made up of transparent pixels. But when I use the ImageIcon, I see this black "frame." How do I get rid of this frame so that the image is displayed naturally as non-rectangular?
Thanks
Matt
[429 byte] By [
MattCaa] at [2007-11-26 12:19:31]

# 1
If your Gif really does have transparency values, Java should handle it fine. The usual cause of ending up with a black background is rendering it to an Image which is configured to be opaque. If you render it via Graphics.drawImage() the transparency will be preserved. If you render it to an Image and want to make some of the image transparent, you will need to start with a transparent Image. You can create one with, for example, new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB).
# 2
itchyscratchyYou're right, insight,you're right, you're right, you're right.right, right, right,insight, insight,,the itchy and Scratchy show...yes, they didn't edit the icon right. I fixed it in Paint.thanks,matt