How to communicate between applet and an applet

Showing Answers 1 - 1 of 1 Answers

An applet can find another applet in the same HTML page by either using the getApplet method to look it up by name or using the getApplets method to find all the applets on the page. Both methods, if successful, return one or more Applet objects to the caller. Once the caller finds an Applet object, it can invoke the Applet's public methods.Suppose that a snippet of the HTML page looks like this:

By using the name attribute in the applet tag, you can refer to a specific applet in the following way: Applet theOtherApplet = getApplet("app1"); theOtherApplet.anyMethod(); //calling any public methodOr, you can use the following code to retrieve all applets on the page: Enumeration allAppletsOnSamePage = getApplets(); while(allAppletsOnSamePage.hasMoreElements()) { Applet appl = (Applet) allAppletsOnSamePage.nextElement(); appl.anyMethod(); //Calling any public method }When the calling applet has retrieved one or several applets on the same HTML page, it can call those applets' public methods.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions