I have an image (gif or png) with some transparents parts which appear in black when put inside a JLabel.
ClassLoader cl = this.getClass().getClassLoader();
ImageIcon img = new ImageIcon(cl.getResource("resources/myPicture.png"));
label = new JLabel(img);
How do I work around this problem ?
I do not need the JLabel, maybe there is a better way to display the image correctly (i.e. with the transparency) directly on a JPanel ?
Thanks
David
解决方案
Found the culprit !
Actually the picture is getting rescaled before being added to the JLabel and for that, I used BufferedImage.TYPE_INT_RGB instead of BufferedImage.TYPE_INT_ARGB
I really didn't think that the rescaling method could alter this (silly me!), that's why I didn't show it in the code I added to the question...
David