Java Reference
In-Depth Information
Rendering Hints
Graphics2D
declares
void setRenderingHint(RenderingHints.Key
hintKey, Object hintValue)
for setting one of the rendering hints used
by the rasterizer. Call its companion
Object getRenderin-
gHint(RenderingHints.Key hintKey)
methodtoreturnthecurrentvalueof
the specified rendering hint.
Thevaluepassedto
hintKey
isa
java.awt.RenderingHints.Key
constant
declared in the
RenderingHints
class (e.g.,
KEY_ANTIALIASING
).The value is
one of the value constants declared in this class (e.g.,
VALUE_ANTIALIAS_ON
).
The following example shows you how to activate antialiasing:
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
Figure 7-25
reveals the difference between aliased and antialiased text.
Figure 7-25.
Select Rendering Hints from the Demo menu to view the rendering hints
demonstration.