... endpoints, and lines 35–36 generate a random color. Line 39 creates a new MyLine
object with the randomly generated values and stores it in the array. Finally, lines 43–47 clear the Canvas
then iterate through the MyLine
objects in array lines
using an enhanced for
statement. Each iteration calls the current MyLine
’s draw
method and passes it the Canvas
’s GraphicsContext
. The MyLine
object actually draws itself.
Get Java How to Program, Early Objects, 11th 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.