Chapter 14, “The java.awt Package: Painting”

The Canvas class of java.awt provides a general GUI component for drawing images and text. It does not support drawing methods of its own, but provides access to a Graphics object via its paint() method.

The paint() method is invoked upon the creation and update of a Canvas object. It enables the Graphics object that is associated with the Canvas object to be updated. The paint() 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 that need repainting. You can implement custom drawing ...

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.