Hello all,
I have created two icons, one with a triangle pointing to the right
and one with a triangle pointing down. Both of the triangles sit upon
a white background in the .jpg files. I am using these icons on
togglebuttons to indicate closed and opened states, respectively.
However, the white background is annoying on a colored panel. I tried
setting the opacity to false, no luck. Does anyone know how I can
make the white background translucent so that the panel color comes
through?
Thanks,
Todd
p.s. The only thing that I have come up with so far is changing the
UI, however, I don't want to write one, if there is one that can do
this for me.
Andrew Thompson - 25 Sep 2007 17:07 GMT
...
>I have created two icons, one with a triangle pointing to the right
>and one with a triangle pointing down. Both of the triangles sit upon
>a white background in the .jpg files.
JPEG images do not support transparency, GIF &
PNG formats do.

Signature
Andrew Thompson
http://www.athompson.info/andrew/
Andrew Thompson - 25 Sep 2007 17:10 GMT
>...
>>I have created two icons, one with a triangle pointing to the right
[quoted text clipped - 3 lines]
>JPEG images do not support transparency, GIF &
>PNG formats do.
..and also. JPEG is a terrible format for simple 'line'
drawings. At high compression, the lines will be blurred,
at low compression, the images will be larger than the
equivalent GIF or PNG.

Signature
Andrew Thompson
http://www.athompson.info/andrew/
Manish Pandit - 25 Sep 2007 18:25 GMT
> Hello all,
>
[quoted text clipped - 14 lines]
> UI, however, I don't want to write one, if there is one that can do
> this for me.
If you are on Windows, use irfanview (http://www.irfanview.com) to
open the jpg images. Then click 'save as', select 'gif' and check the
box that says 'transparent background' or something along those
lines.
For Linux I believe Gimp has something similar.
-cheers,
Manish
Todd - 25 Sep 2007 19:49 GMT
Thanks for all the input - success has been found!!
Roedy Green - 25 Sep 2007 23:19 GMT
>I have created two icons, one with a triangle pointing to the right
>and one with a triangle pointing down. Both of the triangles sit upon
>a white background in the .jpg files.
Ordinary JPGs do not support transparency. You need a png or gif.
You normally insert the transparency with your paint program. You can
also create images programatically with transparency using the alpha
channel.
See http://mindprod.com/applet/masker.html
for an example.
You could also create such an image by painting on a custom JPanel.
Don't clear the background. Just paint the arrow. You don't need to
fool about with the alpha channel.
One other way to do it is to find suitable Unicode glyph and use it in
a JLabel with a font that supports it.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com