[java] antialiasing on buttons' icons

Started by
3 comments, last by cignox1 18 years, 7 months ago
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?
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 :))
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!
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")).
I eat heart attacks
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.

This topic is closed to new replies.

Advertisement