Drawing and Filling
Two kinds of drawing methods are available for many of the shapes you can draw onto a component: draw methods, which draw an outline of the object, and fill methods, which fill in the object with the current color. In each type of method, the outline of the object also is drawn with the current color.
Note
You can also draw bitmap graphics files, such as GIF and JPG files, by using the Image class. You learn about this tomorrow.
Lines
The drawLine() method is used to draw a line between two points. The method takes four arguments: the x and y coordinates of the starting point and the x and y coordinates of the ending point, as follows:
drawLine(x1, y1, x2, y2);
This method draws a line from the point (x1, y1) to the point ...
Get Sams Teach Yourself Java 2 in 21 Days, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.