Interface java.applet.AppletContext

When an Applet is created by an application it lives in (such as a web browser), the application provides it two helper objects to communicate with its environment: AppletStub and AppletContext. The AppletContext object represents the whole environment.

The Applet can access its AppletContext by calling the "getAppletContext" method. You shouldn't call this method from the constructor, because the applet is not fully initialized yet. If you want to keep a reference to the context, obtain it during the "init" method or later.

The AppletContext class provides methods "getAudioClip", "getImage" and "showStatus", which you could also called directly from the applet. (Where they are implemented as calling the respective method from the applet context.) It also provides methods "showDocument" to redirect the browser to a different web page, "getApplets" and "getApplet" to access other applets on the same page, and some methods for associating InputStream objects with String keys (I don't know what is the purpose of this).

Shortly, if you are programming an applet, then AppletContext is useful for cooperating with other applets on the same web page, and redirecting the web browser to another address.

On the other hand, if you are programming an application that is able to embed applets, you are supposed to create one AppletContext instance shared by all applets on your page. Then for each applet you create an AppletStub able to provide a reference to this AppletContext, and then you call the applet's "setStub" method before calling it's "init" method.