draw operation of the
Graphics2D class draws the boundary of a shape by using the currently selected stroke. By default, the stroke is a solid line that is 1 pixel wide. You can select a different stroke by calling the
setStroke method and supplying an object of a class that implements the
Stroke interface. The Java 2D API defines only one such class, called
BasicStroke. In this section, we’ll look at the capabilities of the
You can construct strokes of arbitrary thickness. For example, here is how to draw lines that are 10 pixels wide:
g2.setStroke(new BasicStroke(10.0F)); g2.draw(new Line2D.Double(. . .));
When a stroke is more than a pixel thick, the end of the stroke can have different styles. Figure 7.11 ...