Painting a Container's Components
Containers do not have to explicitly paint the heavyweight components they contain; a container's components are painted (or drawn, if you will) automatically. Custom components that extend Container only need to override their paint(Graphics) method only if they need to perform graphical operations above and beyond painting the components they contain or if they contain lightweight components.[5]
[5] Lightweights are explicitly drawn in Container.paint(). See “Remember to Invoke super.paint() When Overriding Container.paint()” on page 657.
TenPixelBorder
It's about time that we presented some code that illustrates the concepts we've discussed up to this point. We'll start with the TenPixelBorder class, which ...
Get Graphic Java™ 1.2, Volume I: AWT, Third 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.