applet与java程序之间的关系_applet程序之间的通信

[java]代码库import java.applet.*;

import java.awt.*;

import java.awt.event.*;

import java.util.Enumeration;

public class GetApplets extends Applet implements ActionListener {

private TextArea textArea; // 声明一个TextArea

private String newline;

public void init() {

Button b = new Button("Click to call getApplets()");

b.addActionListener(this);

setLayout(new BorderLayout());

add("North", b);

textArea = new TextArea(5, 40);

textArea.setEditable(false);

add("Center", textArea);

newline = System.getProperty("line,separator");

// 取得系统当前的换行符

}

public void actionPerformed(ActionEvent event) {

/* Button b点击后的事件处理函数 */

printApplets();

}

public String getAppletInfo() {

return "GetApplets by Dong.li";

}

public void printApplets() {

Enumeration e = getAppletContext().getApplets();

/* 得到当前网页所有的Applet对象 */

textArea.append("Results of getApplets():" + newline);

while (e.hasMoreElements()) {

Applet applet = (Applet) e.nextElement();

String info = ((Applet) applet).getAppletInfo();

/* 逐个取得当前网页Applet对象的信息 */

if (info != null) {

textArea.append("-" + info + newline);

/* 在textArea中输出网页所有Applet的信息 */

} else {

textArea.append("-" + applet.getClass().getName() + newline);

}

}

textArea.append("__________" + newline + newline);

}

}

694748ed64b9390909c0d88230893790.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值