Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending messages to other applets

Status
Not open for further replies.

outis

Programmer
Jun 20, 2001
21
MX
Hi there.

I need to send a message to other applets but, i have my Send applet in a frame and
my Receiver applet in other frame, can anybody can tell me how to do this.
I use the microsoft internet explorer, and Nestcape 6

I will appreciate your response.
 
Well there are two ways for Applets to communicate with each other.

One is if they are on the same HTML page (not differnt HTML pages in different frames) you need to name your applets in its HTML APPLET tag.
Code:
<APPLET CODE=&quot;Applet.class&quot; CODEBASE=&quot;/appletLocation/&quot; NAME=&quot;myApplet&quot;>
Then in the applet you want to access the above applet you would do the following:
Code:
Applet myApplet = getAppletContext().getApplet(&quot;myApplet&quot;);
You may need to cast the Applet object returned if you added additional methods to your class you need to access.

The only other way will be via a socket connection(RMI, or other network communication). If the applet is part of another HTML file then it will have to use a socket connection. If the applets reside on the same server then you should not have to worry about breaking the applet security sandbox. If they are not then they will need to be signed, or users local java.policy files changed to allow the functionality you need.

So if you do not have to use frames on your web page it would be easier.

Anyways I hope this helps...

Rodney

P.S.
My personal option is to never to frames. They were useful back in early versions of HTML but since HTML 3.2 Tables have become very powerful and robust that you can layout your page very nicely with out frames. Also if you are worried about saving time with repeate code like button banners, etc. You can use various CGI scripts, and other scripting languages that can dynamicly embed multiple html pages in to a single html page at the time the page is called. This way you only really have one file containing the html code, but it is shared among tons of pages. You get html code reuse :).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top