9.3. An Example Applet
Listing 9.3 presents an applet that follows the pattern shown in the previous section. The details of the various steps the applet performs are covered in later sections, but the basic approach is what is important here. The variable declaration section declares a variable of type Image. The init method sets the default color and font, loads an image file from the network and assigns it to the Image declared earlier, adds a label to the applet, then performs an informational printout. The paint method draws the image, placing its top 50 pixels from the top of the applet. Listing 9.4 shows the associated HTML document; the result in Internet Explorer 5.0 (Windows 2000) is shown in Figure 9-1.