FileDocCategorySizeDatePackage
AppletFrame.javaAPI DocExample3602Sat Sep 12 03:01:00 BST 1998None

AppletFrame

public class AppletFrame extends Frame

Fields Summary
Constructors Summary
public AppletFrame(String name)

       // call java.awt.Frame(String) constructor
       super(name);
    
Methods Summary
public booleanhandleEvent(java.awt.Event e)

       // Window Destroy event
       if (e.id == Event.WINDOW_DESTROY)
       {
          // exit the program
          System.exit(0);
          return true;
       }
       
       // it's good form to let the super class look at any 
       // unhandled events
       return super.handleEvent(e);

    
public static voidstartApplet(java.lang.String className, java.lang.String title, java.lang.String[] args)

       // local variables
       Applet a;
       Dimension appletSize;

       try 
       {
          // create an instance of your applet class
          a = (Applet) Class.forName(className).newInstance();
       }
       catch (ClassNotFoundException e) { return; }
       catch (InstantiationException e) { return; }
       catch (IllegalAccessException e) { return; }

       // initialize the applet
       a.init();
       a.start();
  
       // create new application frame window
       AppletFrame f = new AppletFrame(title);
  
       // add applet to frame window
       f.add("Center", a);
  
       // resize frame window to fit applet
       // assumes that the applet sets its own size
       // otherwise, you should set a specific size here.
       appletSize =  a.size();
       f.pack();
       f.resize(appletSize);  

       // show the window
       f.show();