From one applet, how do I communicate with another applet loaded from the same server?

Andre van Dalen

It really doesn't matter that they are loaded from the same server, as long as they are running in the same JVM in the browser, you can call methods between them.

If you include a name="appletA" value in the applet tag of the applet you want to call methods on, you get a reference to it by using the AppletContext:

MyApplet appl = (MyApplet) getAppletContext().getApplet("appletA");
if (null != appl) {
    appl.register("Hello there!", this);

Checking that you get a reference to the class you expect is left as an exercize to the reader :-)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact