The Canvas and Graphics Classes

The Canvas class of java.awt provides a general GUI component (it extends Component) for drawing images and text (or anything else) on the screen. It does not support drawing methods of its own, but it does provide access to a Graphics object via its paint() method.

The paint() method is invoked upon the creation and update of a Canvas object. The paint() method enables the Graphics object that is associated with the Canvas object to be updated. This method should not be directly invoked, but it can be indirectly accessed using the repaint() method. The AWT creates a background thread that automatically causes the paint() methods of Canvas, Frame, Panel, Applet, and other GUI components as required to update areas ...

Get Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams 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.