The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form

Trail: Writing Applets

Lesson: Taking Advantage of the Applet API

The applet API lets you take advantage of the close relationship that applets have with Web browsers. The API is provided by the java.applet package -- mainly by the Applet class and the AppletContext interface. Thanks to the applet API, applets can do the following:

This lesson discusses each of these topics in turn, except for the milestone methods (init, start, and so on), which are explained in Methods for Milestones (in the Writing Applets trail). For information about how to use non-applet-specific API in an applet, see the Practical Considerations when Writing Applets (in the Writing Applets trail) lesson.

The Applet getCodeBase and getDocumentBase methods get information from the browser about where the applet and its HTML page came from. Finding and Loading Data Files describes how to use these methods to help you load your applet's data files, such as images.

Displaying Short Status Strings describes how to make an applet display a string on the status line of the application in which it is running.

Displaying Documents in the Browser tells you how to use the two showDocument methods to request that the browser visit a particular URL.

Using the AppletContext getApplet and getApplets methods, an applet can get the Applet objects for other applets running on the same page. Once an applet has another's Applet object, the applet can send messages to it. Sending Messages to Other Applets provides details and example applets that communicate with each other.

The Applet class and AudioClip interface provide support for playing sounds. The Playing Sounds section tells you about this support and includes an example of using sound in an applet.

You can improve the versatility of your applet by providing parameters. Defining and Using Applet Parameters describes how to decide which parameters to provide, how to implement them, and how to inform the user about them.

Finally, Using the <APPLET> Tag tells you how to customize an applet by editing its HTML tag.


Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form

Copyright 1995-2004 Sun Microsystems, Inc. All rights reserved.