O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required