17.6. When to Use Exceptions

 
[Page 535]

Chapter 16. Applets and Multimedia

Mayan God Shel, Mexico. Photographer: Philip Coblentz. Courtesy Brand X Pictures.

Objectives

  • To explain how the Web browser controls and executes applets ( §16.2).

  • To describe the init , start , stop , and destroy methods in the Applet class ( § §16.2.1 “16.2.4).

  • To develop Swing applets using the JApplet class ( §16.3).

  • To know how to embed applets in Web pages ( §16.4).

  • To run applets from the appletviewer and from Web browsers ( § §16.4.1 “16.4.2).

  • To write a Java program that can run as both an application and an applet ( §16.5).

  • To pass string values to applets from HTML ( §16.6).

  • (Optional) To locate resource (images and audio) using the URL class ( §16.9).

  • (Optional) To play audio ( §16.10).

  • (Optional) To package and deploy Java projects using Java archive files ( §16.12).


[Page 536]

16.1. Introduction

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.

 


Introduction to Java Programming-Comprehensive Version
Introduction to Java Programming-Comprehensive Version (6th Edition)
ISBN: B000ONFLUM
EAN: N/A
Year: 2004
Pages: 503

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