FileDocCategorySizeDatePackage
GetApplets.javaAPI DocExample1335Tue Dec 12 18:57:30 GMT 2000None

GetApplets

public class GetApplets extends Applet

Fields Summary
private TextArea
textArea
Constructors Summary
Methods Summary
public booleanaction(java.awt.Event event, java.lang.Object o)

        printApplets();
        return false;
    
public java.lang.StringgetAppletInfo()

        return "GetApplets by Kathy Walrath";
    
public voidinit()

        setLayout(new BorderLayout());

        add("North", new Button("Click to call getApplets()"));

        textArea = new TextArea(5, 40);
        textArea.setEditable(false);
        add("Center", textArea);

        validate();
    
public voidprintApplets()

        //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");