Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 18-02-2010
Member
 
Join Date: Jul 2006
Posts: 128
How to Communicate with other Applets?

Hi Friends,
I have recently started with an Applets. I have done some basic things in the applets. Now I want to communicate with the other applets.!! I have read that we can communicate with the other applets. But I don't know how to communicate. So thought that someone would be interested in helping me. Please tell me how to Communicate with other Applets.?? Hope that you guys will help me soon.!!
__________________
"Every man is guilty of all the good he did not do". - Voltaire
Reply With Quote
  #2  
Old 18-02-2010
Member
 
Join Date: Mar 2008
Posts: 672
Re: How to Communicate with other Applets?

An applet can communicate with other applets by using JavaScript functions in the parent web page. By receiving messages from one applet and invoking methods of other applets, the JavaScript functions enable communication between applets. The applets may communicate with other applets running in the same virtual machine. If you are trying to communicate the applets of the same class, then they can communicate via shared static variables. And if you are trying to communicate the applets are of different classes, then they will need a reference to the same class with static variables.
Reply With Quote
  #3  
Old 18-02-2010
Member
 
Join Date: Nov 2005
Posts: 1,323
Re: How to Communicate with other Applets?

Yes, you can make an applet to communicate with an applet is another page. Usually it does not support this type of communication, since an AppletContext will be created for a single page.To enable communication with another applet, obtain a reference to an instance of the netscape.javascript.JSObject class. You will need to create the sender applet and the Sender applet uses an instance of the netscape.javascript.JSObject class to invoke a JavaScript function called sendMsgToIncrementCounter. The following is the sample of the same :
Code:
try {
    JSObject window = JSObject.getWindow(this);
    window.eval("sendMsgToIncrementCounter()");
} catch (JSException jse) {
    ...
}
Reply With Quote
  #4  
Old 18-02-2010
Member
 
Join Date: Aug 2006
Posts: 235
Re: How to Communicate with other Applets?

I would like to add that for communication you will have to create Sender and Receiver Applet as well. For the receiver applet you will have to write the JavaScript function that will receive requests from one applet and invoke methods of another applet on the web page. The sendMsgToIncrementCounter JavaScript function invokes the Receiver applet's incrementCounter method. The following script explains the same :
Code:
<script>
    function sendMsgToIncrementCounter() {            
        receiver.incrementCounter();
    }
<script>
__________________
3.2 (northwood)
2gig ram
ATI AIW X800xt 256mb
Gigabyte GA-8knxp 875p Chipset
Optiwrite 8X DVD Burner
Win XP PRO Sp2 (Works Perfectly)
2 SATA Raptor 74gig Raid 0
2 7200 IDE 320gig HD
Reply With Quote
  #5  
Old 18-02-2010
Member
 
Join Date: Jul 2006
Posts: 289
Re: How to Communicate with other Applets?

For communicating the other applets you will also need to Deploy the applets on the web page. The following code shows the sender applet :
Code:
<script src="URL goes here"></script>
<script> 
    var attributes = { code:'Sender.class',
        archive:'demos/example/applet_SenderReceiver/applet_SenderReceiver.jar',  width:250, height:70} ;
    var parameters = {};
    deployJava.runApplet(attributes, parameters, '1.6');
</script>
And the following is a sample of the receiver applet :
Code:
<script> 
    var attributes = { id:'receiver', code:'Receiver.class',
        archive:'demos/example/applet_SenderReceiver/applet_SenderReceiver.jar',  width:250, height:70} ;
    var parameters = {};
    deployJava.runApplet(attributes, parameters, '1.6');
</script>
__________________
Signatures reduce available bandwidth
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to Communicate with other Applets?"
Thread Thread Starter Forum Replies Last Post
Logitech G19 Applets are missing Micro-Dona Hardware Peripherals 3 22-05-2012 03:38 PM
Applets V/s Swing in JAVA "Dritan" Software Development 3 14-12-2010 09:04 AM
How to use applets? Gunner 1 Software Development 5 25-02-2010 02:12 AM
How to Develop a Draggable Applets? N I C K Software Development 5 18-02-2010 03:00 AM
How to Make Applets in Java? NGV BalaKrishna Software Development 4 10-02-2010 07:05 AM


All times are GMT +5.5. The time now is 07:29 PM.