FileDocCategorySizeDatePackage
loadApplet.javaAPI DocExample1293Thu Apr 03 15:26:36 BST 1997None

loadApplet

public class loadApplet extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


    int x = 50;
    int y = 50;

    for (int i = 0; i < args.length; i++) {
      try {
        if (!args[i].endsWith(".class")) {
          System.err.println("That doesn't look like a byte code file!");
          break;
        }
      
        URL u = new URL(args[i]);
        URLClassLoader ucl = new URLClassLoader(u);
        
        // parse out the name of the class from the URL
        String s = u.getFile();
        String classname = s.substring(s.lastIndexOf('/"), 
         s.lastIndexOf(".class"));
        System.err.println(classname);
        Class AppletClass = ucl.loadClass(classname, true);
        Applet apl = (Applet) AppletClass.newInstance();
        
        Frame f = new Frame();
        f.resize(200, 200);
        f.move(x, y);
        x += 50;
        y += 50;
        f.add("Center", apl);
        apl.init();
        apl.start();
        f.show();
      
      }  // end try
      catch (MalformedURLException e) {
        System.err.println(args[i] + " is not a URL I understand.");
      }
      catch (Exception e) {
        System.err.println(e);
      }
    
    }  // end for