Appendix B. Internet-Ready Applets

Table of contents:

When the Java™ technology was first introduced, much of the surrounding hype focused on applets because they allow programs to be downloaded to a browser and to run on the fly over the Internet. It's important to keep in mind that applets are just another way of delivering a program. Newer ways of delivering programs are continually being invented, one example is Java WebStart. [1]

[1] You can learn more about Java WebStart at:

Applets can run in any browser with a Java Virtual Machine. However, the major browsers haven't kept up with the latest releases of the Java 2 Platform. To ensure that most users can run your applets, you have two options:

  • You can create applets that use the JDK 1.1 API. [2] Most Netscape Navigator and Internet Explorer browsers in use will run applets written to the 1.1 API.

    [2] JDK 1.1 is an earlier release of the Java SDK.

  • You can use the Java Plug-in solution, which installs as an extension to either Internet Explorer or Netscape Navigator browsers. [3] The Java Plug-in does not replace or modify the browser's underlying Java runtime; rather, Java Plug-in allows a Web author to specify the use of Sun Microsystems' Java runtime environment (JRE) for a given Web page.

    [3] The Plug-in is now included in Sun Microsystems' release of the Java Runtime Environment (JRE).

Although the Java Plug-in can guarantee the use of the appropriate virtual machine, it is a hefty download, about 6MB. The plug-in is recommended for use on internal corporate intranets but not for distributing applets on the Internet. For this reason, this appendix presents the information you need to write applets that use the JDK 1.1 API.

This appendix starts by telling you how applets work. The next section covers sound, applet parameters, the tag, interapplet communication, and browser requests.

The appendix then discusses factors to consider when writing the graphical user interface (GUI) for your applet and security restrictions on applets. The next section describes the characteristics of a high-quality applet and includes a checklist of annoying behaviors to avoid in your applet. If you're interested in running applets that use the Java 2 SDK, read the last section, Swing-Based Applets (page 457), which has information on running and writing applets that use Swing GUI components.

Internet-Ready Applets

Overview of Applets

A Simple Applet

The Life Cycle of an Applet

Methods for Milestones

Methods for Drawing and Event Handling

Methods for Adding UI Components

What Applets Can and Cannot Do

Test Driving an Applet


AWT Components

AWT Basic Controls

Other Ways of Getting User Input

Creating Custom Components



Other AWT Classes

Taking Advantage of the Applet API

Finding and Loading Data Files

Displaying Short Status Strings

Displaying Documents in the Browser

Sending Messages to Other Applets

Playing Sounds

Defining and Using Applet Parameters

Using theTag

Practical Considerations of Writing Applets

Security Restrictions

Creating a User Interface

Displaying Diagnostics to the Standard Output and Standard Error Streams

Getting System Properties

Threads in AWT Applets

Finishing an Applet

Before You Ship That Applet

The Perfectly Finished Applet

Swing-Based Applets

Running Swing-Based Applets

Writing Swing-Based Applets

Providing an OBJECT/EMBED Tag for Java Plug-in

Converting AWT Applets to Swing Applets

For More Information

Code Samples

Overview of Applets

Getting Started

Object-Oriented Programming Concepts

Language Basics

Object Basics and Simple Data Objects

Classes and Inheritance

Interfaces and Packages

Handling Errors Using Exceptions

Threads: Doing Two or More Tasks at Once

I/O: Reading and Writing

User Interfaces That Swing

Appendix A. Common Problems and Their Solutions

Appendix B. Internet-Ready Applets

Appendix C. Collections

Appendix D. Deprecated Thread Methods

Appendix E. Reference

The Java Tutorial(c) A Short Course on the Basics
The Java Tutorial: A Short Course on the Basics, 4th Edition
ISBN: 0321334205
EAN: 2147483647
Year: 2002
Pages: 125 © 2008-2020.
If you may any questions please contact us: