StarLover
To find the lost memorise...

希望实现一个Applet与另外一个Applet进行通讯时,必须用getAppletContext()方法先取得另外一个Applet的句柄,再用getAplplet(name)方法取得Applet,具体代码实例如下:

AppletContext ac = getAppletContext();

Applet applet = ac.getContext(“other”);

 

TextArea text = (TextArea)applet.getComponent(2);

Text.append(“good luck”+”\n”);

 

其中other是另外一个Applet的名字:

<html>

       <applet code = “applet.java” width=”300” height=”200” name=”other”>

</applet>

</html>

 

 

getComponent(2)中的参数“2”是指添加到Applet中的组件的次序(从1开始);

这样我们就能操纵另外一个Applet中的组件了。

2005年12月18日

posted on 2005-12-18 12:44 StarLover 阅读(593) 评论(1)  编辑  收藏
Comments
  • # re: Applet之间的通讯[未登录]
    liu
    Posted @ 2008-03-04 23:11
    applet.getComponent(2);
    还是不明白2 是为什么??  回复  更多评论   

只有注册用户登录后才能发表评论。


网站导航: