Java Reference
In-Depth Information
Figure 7-18.
Select Paint from the Demo menu to view the paint demonstration.
Stroke
Graphics2D
declares
void setStroke(Stroke stroke)
for setting the
strokeattribute.Passanyobjectwhoseclassimplementsthe
java.awt.Stroke
in-
terface to
stroke
. Call
Stroke getStroke()
to return the current stroke.
HOW STROKING WORKS
Stroking
is the act of drawing a shape's outline. The first step is to call
setStroke()
tospecifyhowyouwanttheoutlinetobedrawn(e.g.,itswidthand
whether it is solid or consists of a mixtures of dashes and spaces). The next step is
tocall
setPaint()
tospecifyhowyouwanttheoutlinetobepainted(e.g.,using
solidcolors,gradients,ortextures).Thefinalstepistodrawtheoutlinevia
Graph-
ics2D
's
draw()
method.