inthe paint() methodbecausetheycanmaketheuserinterfacelessperform-
ant. Shorter loops are not a problem.
• I center the bottom string horizontally by subtracting the total advance width
(returned from stringWidth() ) from the canvas's width and dividing the
result by 2. I center the string's baseline vertically by dividing the canvas's
height by 2.
shadow color) and then drawing the same string in red, but offset three pixels
horizontally and three pixels vertically.
a blue rectangle.
Figure 7-9. A canvas can be used to paint an application's splash screen.
so.Forexample, Component alsodeclaresa void update(Graphics g) meth-
od for updating a heavyweight component in response to a repaint() method call.
You can learn about this method and more by reading “Painting in AWT and Swing”