public class Applet1 extends Applet {
public void paint(Graphics g) {
g.drawString("First applet,What can I do?", 20, 30);
//获得同一页面的applet
Applet2 theOtherApplet =(Applet2)getAppletContext().getApplet("app2");
//使用另一个applet的方法
g.drawString(theOtherApplet.whatidoallforyou(),20,60);
public class Applet2 extends Applet {
public void paint(Graphics g) {
g.drawString("Second applet", 10, 15);
g.draw3DRect(0, 0, 100, 20, false);
}
public String whatidoallforyou(){
return "what I do all for you,zly";
}
} ///:~