AppletContext Interface

The AppletContext interface provides the means to control the browser environment where the applet is running. Methods

Some of these methods are so frequently used that they are also provided within the Applet class.

The getApplets() method gathers all the Applets in the current context, loaded by the same ClassLoader, into a collection and returns the Enumeration. You can then cycle through them to perform some operation collectively. For example:

Enumeration e = getAppletContext().getApplets(); while (e.hasMoreElements()) {
 Object o = e.nextElement(); if (o instance of MyApplet) {
 MyApplet a = (Object)o; a.MyAppletMethod();
}
} 

TIP:

If you want communication between applets on one page, be aware that there is no guarantee which applet will start first. Communications must be synchronized by using a controlling class or continual polling.

The showDocument() method shows url in the current browser window. The browser may ignore the request if it so desires.

The showDocument() method shows url in a browser window specified by frame. Different frame values and the results are shown in Table 14.1. The browser may ignore the request, as appletviewer does.

try {
 URL u = new URL (getDocumentBase(), (String) file); getAppletContext().showDocument (u, "_blank");
}
catch (Exception e) {
}
Target Values
Target String Results
_blank Show url new browser window with no name.
_parent Show url in the parent frame of the current window.
_self Replace current url with url (i.e., display in the current window).
_top Show url in top-most frame.
name Show url in new browser window named name.