O'Reilly logo

Java, A Beginner’s Guide, 5th Edition by Herbert Schildt

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

Create a Swing Applet

The preceding example programs have been Swing-based applications. The second type of program that commonly uses Swing is the applet. Swing-based applets are similar to AWT-based applets described in Chapter 14, but with an important difference: A Swing applet extends JApplet rather than Applet. JApplet is derived from Applet. Thus, JApplet includes all of the functionality found in Applet and adds support for Swing. JApplet is a top-level Swing container. Therefore, it includes the various panes described earlier. As a result, all components are added to JApplet’s content pane in the same way that components are added to JFrame’s content pane.

Swing applets use the same four lifecycle methods described in Chapter 14:

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