⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getapplets.java

📁 北大Java 语言程序设计 ppt课件及源码
💻 JAVA
字号:
/* * 1.0 code. */import java.applet.*;import java.awt.*;import java.util.Enumeration;public class GetApplets extends Applet {    private TextArea textArea;    public void init() {        setLayout(new BorderLayout());        add("North", new Button("Click to call getApplets()"));        textArea = new TextArea(5, 40);        textArea.setEditable(false);        add("Center", textArea);        validate();    }    public boolean action(Event event, Object o) {        printApplets();        return false;    }    public String getAppletInfo() {        return "GetApplets by Kathy Walrath";    }    public void printApplets() {        //Enumeration will contain all applets on this page (including        //this one) that we can send messages to.        Enumeration e = getAppletContext().getApplets();        textArea.appendText("Results of getApplets():\n");        while (e.hasMoreElements()) {            Applet applet = (Applet)e.nextElement();            String info = ((Applet)applet).getAppletInfo();            if (info != null) {                textArea.appendText("- " + info + "\n");            } else {                textArea.appendText("- " + applet.getClass().getName() + "\n");            }         }        textArea.appendText("________________________\n\n");    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -