Chapter 16. Applets

An applet, as the name implies, is a kind of mini-application, designed to be run by a web browser or in the context of some other "applet viewer." Java 1.0 was released in the early days of the World Wide Web, and it was applets that drove the adoption of the language. In those days (late 1995 and early 1996) web browsers could not display animated GIFs, much less Flash animations, and client-side scripting languages like JavaScript did not exist yet. At that time, the ability to embed a Java applet on a web page opened up a world of interactive web content that was not possible in any other way. Browser vendors responded by bundling Java with their browsers. Java programming became wildly popular, and programmers put silly animations on their web pages. In the first edition of this book, this chapter on applets was right up front as Chapter 3.

Times have changed. Applets no longer rule the Web. Dynamic web content is usually provided by Flash animations and JavaScript-driven DHTML (see my book JavaScript: The Definitive Guide for details). Applets have found a niche in large high-end applications, such as delivering streaming stock quotes, and for providing scientific or mathematical visualizations in online course notes, but they are no longer commonplace. The Java platform has grown too big to bundle with web browsers, and Java support is now relegated to plug-in status. And this chapter has been banished to its relatively obscure present location.

This chapter demonstrates the techniques of applet writing. It proceeds from a trivial "Hello World" applet to more sophisticated applets. Along the way, it explains how to:

  • Draw graphics in your applet

  • Handle and respond to simple user input

  • Read and use values of applet parameters, allowing customization of an applet

  • Load and display images and load and play sounds



Java Examples in a Nutshell
Java Examples in a Nutshell, 3rd Edition
ISBN: 0596006209
EAN: 2147483647
Year: 2003
Pages: 285

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net