FileDocCategorySizeDatePackage
AppApp.javaAPI DocExample1332Tue Mar 13 22:36:10 GMT 2001None

AppApp

public class AppApp extends Applet
Example of a class that can be used as an Applet or an Application
author
Ian F. Darwin, ian@darwinsys.com
version
#Id$

Fields Summary
boolean
inAnApplet
Label
status
Constructors Summary
Methods Summary
public voidinit()

		// for Application showStatus()

	   
		add(new Label("This is my demo Applet"));
		showStatus("My applet is running");
	
public static voidmain(java.lang.String[] av)

		AppApp app = new AppApp();
		final Frame f = new Frame("AppApp Demo");
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				f.hide();
				f.dispose();
			}
		});
		f.setLayout(new BorderLayout());
		app.inAnApplet = false;
		f.add("Center", app);
		// Must do this before init() since init() may use showStatus()
		f.add("South", app.status = new Label());
		f.setSize(300, 200);
		app.status.setSize(f.getSize().width, app.status.getSize().height);

		// Here we pretend to be a browser!
		// A fancier version would make an AppletStub and pass it
		// into the Applet with getAppletStub().
		app.init();
		app.start();

		f.setVisible(true);
	
public voidshowStatus(java.lang.String s)

		 if (inAnApplet) {
			 super.showStatus(s);	// call version in Browser
		 } else {
			 status.setText(s);		// do it yourself.
		 }