Now we’re ready to create some graphics. Let’s start with drawing lines.
Table 4.5 shows some useful methods of the GraphicsContext class for drawing shapes and displaying text in a window.
As you can see, all these methods have a void return type, so they do not return a value. Method calls to these methods should be stand-alone statements.
The pattern for the method names is simple. The draw methods render the outline of the figure, while the fill methods render solid figures. The clearRect method draws a rectangle in the background color, which effectively erases anything drawn within that rectangle.
Figure 4.4 shows the relationship among the method arguments and the figures drawn.