• Advertisement
Sign in to follow this  

[java] antialiasing on buttons' icons

This topic is 4521 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well, if you keep attention and magnify the toolbars icons of programs such like netscape, emule, netbeans (and, I suppose, most modern apps) you will see that icons are antialiased. Simply setting an image on a JButton does not provide the effect, then what should I do?

Share this post


Link to post
Share on other sites
Advertisement
Use PNG as your image format, because it has an 8-bit alpha channel. In your paint program, set the background to "transparent" and do your painting / text creation anti-aliased, and it will anti-alias with "transparent" by using partially transparent pixels gradated smoohtly to fully opaque ones.

This image will then ALWAYS be FULLY anti-aliased on ANY colour background :). Since Java has full support for PNG, this should always work (if not, it's a bug :))

Share this post


Link to post
Share on other sites
Thank you. Actually, I really hoped not to have to do that this way, because I'm painting the icons by hand and then I scan them and I don't know how to add the alpha-channel so that they look as antialiased. I hoped to find something like

xyzclass.setAntiAliasingEnabled(true);

but perhaps it was asking too much :-)

thank you again!

Share this post


Link to post
Share on other sites
There is a method to antialias the text. Set the property swing.aatext to true either by running it as a command line parameter (-Dswing.aaxtext=true) or set it during runtime (System.setProperty("swing.aatext","true")).

Share this post


Link to post
Share on other sites
Quote:

There is a method to antialias the text. Set the property swing.aatext to true either by running it as a command line parameter (-Dswing.aaxtext=true) or set it during runtime (System.setProperty("swing.aatext","true")).


Yes, that's why I hoped for a simple function call to solve my problem. But since I must deal with alpha channels, I did it and it works really well.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement