怎么实现applet之间的通信?急问!!!最好有源代码说明,谢谢了!1

解决方案 »

  1.   

    比如,我点击一个applet(名称为”A“)上的按钮Send时,就发送一个字符串”11111“,给另一个applet(名称为”B“),这两个applet在同一个jsp页面中,都用jsp:plugin动作元素插入的。
      

  2.   

    applet.getAppletContext().getApplets();
      

  3.   

    我的jsp代码如下:(在同一个jsp页面中的)
    <jsp:plugin type="applet" codebase="starmap" code="starmap.ZoneMonitorApplet.class" align="left" height="550" width="660" hspace="0" vspace="0" jreversion="1.4" />  
    <table width="299" height="516" border="0" align="center" cellspacing="1" bgcolor="#0000ff">
        <tr>
          <td width="295" height="25" bgcolor="#D6E6FC"><div align="center" class="style18">区域监控</div></td>
        </tr>
        <tr>
          <td height="510" bordercolor="0" bgcolor="#D6E6FC" class="a1" cellspacing="1"><div align="center">
    <jsp:plugin type="applet" codebase="starmap"  name="friend" code="starmap.ZoneMonitorA.class" align="left" height="500" width="300" hspace="0" vspace="0" jreversion="1.4">
    <jsp:params>  
        <jsp:param name="groupterminals" value="<%=gsGroupAndTerminals%>" />
        </jsp:params> 
        <jsp:fallback>在插入Applet时产生错误</jsp:fallback>
        </jsp:plugin>
      </div></td>
        </tr>
    </table>我在ZoneMonitorApplet中用如下方法,试图取得名为”friend“的applet:
     ZoneMonitorA  talker2=(ZoneMonitorA)getAppletContext().getApplet("friend"); 
     if(talker2==null)
           JOptionPane.showMessageDialog(null, "2222", "错误!", -1);
     else
    {
       talker2.setUpLongitudeValue("11111111");
    }结果是talker2==null, 为什么会得不到要通信得applet的对象呢??