Applet Programming
Applets, as Panels, conform to what was discussed about GUI programming in Chapter 8. This means you can add components to an applet, set the layout manager, add event listeners, and process user interaction. Yet, there are some things that applets are particularly good at, such as displaying images. The remainder of the chapter is devoted to showing how to code applets.
A Simple Applet: Code Example
Listing 9.2 illustrates code to show a minimal applet with some GUI components on it. Figure 9.1 shows the applet running in AppletViewer.
Code Listing 9.2. A Basic Applet Coding Example (BookSearch.html)
<HTML> <TITLE> Basic Applet Example for Pure Java </TITLE> <BODY> <Applet code=BookSearchApplet.class height=100 width=200> ... |
Get PURE Java™ 2 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.