希望實現一個Applet與另外一個Applet進行通訊時,必須用getAppletContext()方法先取得另外一個Applet的句柄,再用getAplplet(name)方法取得Applet,具體代碼實例如下:
AppletContext ac = getAppletContext();
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日