![]() |
|
Articles >> Java >> Inter-applet communication
Java: Inter-applet communicationWhat?Using the AppletContext getApplet(String) and getApplets() methods, an applet can get Applet objects from the applets list running on the same page. Once an applet has another's Applet context, the first one is able to invoke methods on the second one.Why?Getting two or more applets within a single Web page to talk to each other has some benefits:
How?The following sample shows the inter-applet communication working. A first applet, named "RC Toy", displays a square cursor. The second applet, named "Remote Control" and figuring a joystick, allows moving the first applet's cursor. The first applet implements the convenience, user defined, RemotelyControllable interface, specifying for this example the method that the "Remote Control" will use to move the cursor.The most significant code parts are highlighted below. Feel free to download, test and play with the whole source code. Please notice that the Genuts Framework is required.
And now, what are you going to control with your joystick? Links
Articles >> Java >> Inter-applet communication
|