Results 1 to 5 of 5

Thread: How to Communicate with other Applets?

  1. #1
    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

  2. #2
    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.

  3. #3
    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) {
        ...
    }

  4. #4
    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

  5. #5
    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

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,978,937.97857 seconds with 17 queries