import java.awt.*; import java.applet.Applet; public class AppletRunner { static AppletFramer frame; static String appletname; static int width, height; public static void main (String[] args) { if (args.length != 3) System.out.println("usage: java AppletRunner "); else { appletname = args[0]; width = Integer.parseInt(args[1]); height = Integer.parseInt(args[2]); frame = new AppletFramer(appletname, width, height); } } } class AppletFramer extends Frame { Applet applet; AppletFramer (String appletname, int width, int height) { setLayout(new BorderLayout()); try { // get the class from its name and instantiate it applet = (Applet) Class.forName(appletname).newInstance(); } catch (Exception e) { System.out.println(e); } resize(width, height); add("Center", applet); // the applet is a panel applet.init(); applet.start(); show(); } public boolean handleEvent (Event evt) { if (evt.id == Event.WINDOW_DESTROY) { applet.destroy(); dispose(); System.exit(0); } else if (evt.id == Event.WINDOW_ICONIFY) { applet.stop(); } else if (evt.id == Event.WINDOW_DEICONIFY) { applet.start(); } return super.handleEvent(evt); } }