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"); ...

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.