Objectives |
|
Java's early success has been attributed to applets. Running from a Java-enabled Web browser, applets bring dynamic interaction and live animation to an otherwise static HTML page. It is safe to say that Java would be nowhere today without applets. They made Java instantly appealing, attractive, and popular during its infancy. Java is now used not only for applets, but also for standalone applications and as a programming language for developing server-side applications and for mobile devices.
In this book so far, you have only used Java applications. Everything you have learned about writing applications, however, also applies to writing applets. Applications and applets share many common programming features, although they differ slightly in some respects. For example, every application must have a main method, which is invoked by the Java interpreter. Java applets, on the other hand, do not need a main method. They run in the Web browser environment. Because applets are invoked from a Web page, Java provides special features that enable applets to run from a Web browser.
In this chapter, you will learn how to write Java applets, discover the relationship between applets and the Web browser, and explore the similarities and differences between applications and applets. You will also learn how to create multimedia applets with images and audio.