23.3 Simple Java Applet: Drawing a String

Every Java applet is a graphical user interface on which you can place GUI components using the techniques introduced in Chapter 14 or draw using the techniques demonstrated in Chapter 15. In this chapter, we’ll demonstrate drawing on an applet. Examples in Chapters 24 and 27 demonstrate building an applet’s graphical user interface.

Now let’s build an applet of our own. We begin with a simple applet (Fig. 23.6) that draws “Welcome to Java Programming!” on the applet. We show this applet executing in two applet containers—the appletviewer and the Mozilla Firefox web browser. At the end of this section, you’ll learn how to execute the applet in a web browser.

Fig. 23.6 Applet that draws a String ...

Get Java How to Program (early objects), 9/e 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.