/*
 * @(#)DemoApplet.java	 1.1 98/06/16
 *
 * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
 * (C) Copyright IBM Corp. 1996 - All Rights Reserved
 *
 * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
 *
 *   The original version of this source code and documentation is copyrighted
 * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
 * materials are provided under terms of a License Agreement between Taligent
 * and Sun. This technology is protected by multiple US and International
 * patents. This notice and attribution to Taligent may not be removed.
 *   Taligent is a registered trademark of Taligent, Inc.
 *
 */


import java.applet.Applet;
import java.awt.event.*;
import java.awt.*;

public abstract class DemoApplet extends java.applet.Applet implements ActionListener
{
    private Button   demoButton;
    private Frame    demoFrame;

    public abstract Frame createDemoFrame(DemoApplet applet);

    //Create a button that will display the demo
    public void init()
    {
        setBackground(Color.white);
        demoButton = new Button("Demo");
	demoButton.addActionListener(this);
        demoButton.setBackground(Color.yellow);
        add( demoButton );
    }

    public static void showDemo(Frame demoFrame)
    {
        demoFrame.setSize(550,500);
        demoFrame.show();
    }

    public void demoClosed()
    {
        demoFrame = null;
    }

  public void actionPerformed(ActionEvent e) {
    String arg = e.getActionCommand();
    if (arg.equals("Demo")) {
      demoButton.setLabel("loading");
      if (demoFrame == null) {
	demoFrame = createDemoFrame(this);
	showDemo(demoFrame);
      }
      demoButton.setLabel("Demo");
    }
  }

}

