13.1. The Canvas Class
A Canvas is the simplest window and cannot contain any other GUI controls. Furthermore, you must place a canvas inside an existing window because a canvas cannot stand alone. As such, a Canvas does not have a layout manager. A canvas has two major roles:
Drawing area. Suppose that you have a complicated GUI and want to create a custom graph or image. Rather than directly drawing into the underlying window, you may find it more convenient to insert a separate Canvas on which to perform the drawing. Note, however, that the Canvas should draw itself by overriding the paint method.
Custom component. The Canvas is also the starting place for many custom components, for instance, an image label or image button.
Both approaches ...
Get Core Web Programming, 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.