[Ldsoss] AntiAlias Java
Ben Galbraith
junk at galbraiths.org
Fri Aug 25 13:09:17 EDT 2006
On Aug 25, 2006, at 10:58 AM, Jay Askren wrote:
> I tried your code on version of 1.5_04 of java and it didn't work.
> SwingUtilities2 is not mentioned in the javadocs for Java 1.5, so I
> looked at the code for SwingUtilities2 source code, and it appears
> that SwingUtilities2 is not stable, and the the comments said to
> not rely on the class.
Right.
> So it looks like at least for now using the RenderingHints might
> be a bit more robust though I haven't tried it. It should work
> with Java 1.4.
Adding the RenderingHints.KEY_TEXT_ANTIALIASING /
RenderingHints.VALUE_TEXT_ANTIALIAS_ON to the Graphics2D instance
that the component uses to draw text is the *only way* to get Java2D
to draw text using its anti-alias mechanism. Tom was showing a higher-
level way to get Sun's look-and-feel to add this rendering hint to
the graphics context automatically (i.e., without developers needing
to subclass components or install their own UI delegates).
Fortunately, on JDK5, none of this is necessary -- just set the
"swing.aatext" system property to a value of "true". Any look-and-
feel that descends from BasicLookAndFeel (pretty much any look-and-
feel) inherits code that checks if the system property is set and
adds the text-AA rendering hint to the graphics context.
Best,
Ben
More information about the Ldsoss
mailing list