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

Lightweight Containers

Lightweight components extend java.awt.Component, and lightweight containers extend java.awt.Container. In Example 19-4, we've added a lightweight container to the previous applet. Just as with like any other container, we can add components to a lightweight container, which we've done by adding an instance of Lightweight to our lightweight container.

Example 19-4. A Lightweight Container
 import java.applet.Applet; import java.awt.*; public class SimpleLightweightContainer extends Applet { private Image dining, paper; public void init() { dining = getImage(getCodeBase(),"../gifs/Dining.gif"); paper = getImage(getCodeBase(),"../gifs/paper.gif"); ...

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