News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

Sending Messages to Other Applets

Started by sukishan, Jul 15, 2009, 03:13 PM

Previous topic - Next topic

sukishan

Sending Messages to Other Applets
Applets can find other applets and send messages to them, with the following security restrictions:

Many browsers require that the applets originate from the same server.
Many browsers further require that the applets originate from the same directory on the server (the same code base).
The Java API requires that the applets be running on the same page, in the same browser window.

An applet can find another applet either by looking it up by name (using the AppletContext getApplet method) or by finding all the applets on the page (using the AppletContext getApplets method). Both methods, if successful, give the caller one or more Applet objects. Once the caller finds an Applet object, the caller can invoke methods on the object.

Finding an Applet by Name: The getApplet Method
The getApplet method looks through all of the applets on the current page to see if one of them has the specified name. If so, getApplet returns the applet's Applet object.

By default, an applet has no name. For an applet to have a name, one must be specified in the HTML code that adds the applet to a page. You can specify an applet's name in two ways:

By specifying a NAME attribute within the applet's <APPLET> tag. For example:
<APPLET CODEBASE=example/ CODE=Sender.class
    WIDTH=450
    HEIGHT=200
    NAME="buddy">
. . .
</APPLET>

By specifying a NAME parameter with a <PARAM> tag. For example:
<APPLET CODEBASE=example/ CODE=Receiver.class
    WIDTH=450
    HEIGHT=50>
<PARAM NAME="name" value="old pal">
. . .
</APPLET>
A good beginning makes a good ending

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it has been approved by a moderator.

Name:
Email:
Verification:
Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S post or ALT+P preview