
Anti-Aliased Text with a Custom Look and Feel #55
Chapter 7, Text
|
285
HACK
that
SwingUtilities2
is an undocumented and hidden class for which no
support will ever be provided. This means that it can be changed without
notice. Using it might break your applications in a future release of Java.
—Romain Guy
H A C K
#55
Anti-Aliased Text with a Custom
Look and Feel Hack #55
Another way to get smooth text is to use a custom Look and Feel to avoid the
fragile Java 5.0 APIs.
When the Java 5.0 anti-aliasing trick [Hack #54] was first discovered, some dis-
cussions arose on the Web. Many people strongly disagree with using it
because it can be broken at any time by Sun Microsystems. Should we be
deprived of anti-aliased text because of such a silly problem? Frédéric Lav-
igne, author of the famous Skin L&F and webmaster of www.javootoo.com,
a great repository of Look and Feels for Swing, didn’t think so and found an
elegant and clever way to get the same result.
The Wrap Look and Feel
His idea is to use a custom Look and Feel whose sole purpose is to enable
anti-aliasing hints on the
Graphics instances used to draw the UI. He imple-
mented his idea in the Wrap Look and Feel, which can be downloaded at
wraplf.l2fprod.com. Another Look and Feel, SmoothMetal, enables anti-
aliasing in your application. Yet, you are stuck with Metal Look and Feel
when using it. Wrap Look and Feel acts as a decorator for the current