Skip to Content
Java Network Programming, Second Edition
book

Java Network Programming, Second Edition

by Elliotte Rusty Harold
August 2000
Intermediate to advanced
760 pages
21h
English
O'Reilly Media, Inc.
Content preview from Java Network Programming, Second Edition

Network Methods of java.applet.AppletContext

AppletContext is an interface that lets an applet manipulate the environment in which it is running. Every applet has an AppletContext field, which is a reference to an object implementing AppletContext. In some sense, this object represents the web browser or applet viewer that is running the applet. (In rare cases, mostly applets started from the command line and instantiated in the main( ) method, the AppletContext may be null.) To access the applet’s context, call the applet’s getAppletContext( ) method:

public AppletContext getAppletContext(  )

The AppletContext must provide several methods for the use of the applet, including getAudioClip( ) and getImage( ) methods; the getAudioClip( ) and getImage( ) methods of java.applet.Applet merely call the corresponding method in the applet’s AppletContext. However, there are two overloaded showDocument( ) methods in java.applet.AppletContext that are relevant to network programming and are not mirrored in java.applet.Applet. The first takes as an argument a single URL:

public void showDocument(URL url)

This method shows the document at URL url in the AppletContext’s window. It is not supported by all web browsers and applet viewers, but it is supported by Netscape, HotJava, and Internet Explorer. This method is most useful in fancy image map applets, where it is used to send the user to a new page after clicking on a hot button. For example, to send the user to the O’Reilly home page, you ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Network Programming, 4th Edition

Java Network Programming, 4th Edition

Elliotte Rusty Harold
Java Concurrency, 2/e

Java Concurrency, 2/e

Douglas Schmidt

Publisher Resources

ISBN: 1565928709Supplemental ContentCatalog PageErrata