Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

How do I make an icon's background transparent?

Thread view: 
Todd - 25 Sep 2007 16:55 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.