Sunday 25 March 2012

Applet to Applet Communication

•An applet can communicate with another applet by using the “getApplet()” or “getApplets()” method available in the “AppletContext” interface.
•The “Applet” class implements the “AppletContext” interface and provided implementation for these methods.
•getApplet() returns the object of the specified applet.

 Syntax: Applet getApplet(String name)

•getApplets() returns a collection of all the applets present in the document.

Syntax: Enumeration getApplets()


•To use the getApplet() method, we must use another method in the “Applet” class namely the “getAppletContext()”.
•getAppletContext() returns the current context of the applet i.e., the current document(web page).
•Use the following syntax for using the getApplet() method:
Applet obj = getAppletContext().getApplet(“Name of the Applet”);
•After obtaining the object to the required applet, you can access any public methods in that applet class.

No comments:

Post a Comment