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

Loading and Displaying Images

Let's begin by taking a look at a very simple applet, shown in Figure 5-1 and listed in Example 5-1, that obtains a JPEG image and displays it.

Figure 5-1. A Simple Applet That Displays an Image

The applet prints the codebase—the URL defining the location of the applet—and the image's width and height, solely for the sake of illustration.

Example 5-1. A Simple Applet That Displays an Image
 import java.net.URL; import java.applet.Applet; import java.awt.Graphics; import java.awt.Image; public class ImageTestAppletSimple ...

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