收录日期:2019/03/26 02:54:07 时间:2009-08-05 19:41:54 标签:java,swing,antialiasing

I remember, not too long ago, somebody post a link on how to specify the global rendering hints to use anti-alias in java.

Unfortunately I can't find the question.

How can I specify the rendering hint to use anti-alias in swing?

For a single Graphics2D:

Graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
             RenderingHints.VALUE_ANTIALIAS_ON);

Call that on the Graphics2D you are drawing on, and you will have anti-aliasing!!

For global settings:

//this SHOULD enable global anti-aliasing
System.setProperty("awt.useSystemAAFontSettings","on");
System.setProperty("swing.aatext", "true");

EDIT By oreyes:

The first one did it!!!

alt text

vs.

alt text