You create containers all the time when you write Java beans. Any bean that can hold another bean is a container. For instance, all beans extended from an Abstract Windowing Toolkit (AWT) control are containers. In this section, you write a simple Dot bean and a container bean, which is extended from the java.awt.Panel class, named MyContainer1. You add Dot beans to the container bean.
The Dot bean is extended from the java.awt.Canvas class and displays a small red circle. The code is shown in Listing 8.1. The reason for creating the Dot bean is to have something for a container bean to hold.
package sams.containers; import java.awt.Canvas; import java.awt.Color; ...