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

GetApplets

public class GetApplets extends Applet implements ActionListener

Fields Summary
private TextArea
textArea
private String
newline
Constructors Summary
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent event)

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

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

        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 voidprintApplets()

        //Enumeration will contain all applets on this page
        //(including this one) that we can send messages to.
        Enumeration e = getAppletContext().getApplets();

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

        while (e.hasMoreElements()) {
            Applet applet = (Applet)e.nextElement();
            String info = ((Applet)applet).getAppletInfo();
            if (info != null) {
                textArea.append("- " + info + newline);
            } else {
                textArea.append("- " 
				+ applet.getClass().getName() 
                                + newline);
            } 
        }
        textArea.append("________________________" 
                        + newline + newline);