//
//  This example shows how to create
//  frames in applet.
//
import java.applet.*;
import java.awt.*;

public class FrameExampleApplet3 extends Applet {

  CustomFrame frame;
  Button button;

  public void init () {
    frame = new CustomFrame("Custom Frame Window");
    button = new Button("Show Window");
    add(button);
  }
  public boolean action(Event evt, Object arg)
  {
    boolean visible = frame.isShowing();
    if (visible)
    {
      frame.hide();
      button.setLabel("Show Window");
    }
    else
    {
      frame.show();
      frame.resize(200,100);
      button.setLabel("Hide Window");
    }
    return true;
  }
}
class CustomFrame extends Frame
{
  Button button;
  CustomFrame(String title)
  {
    super(title);
    setLayout(new FlowLayout());

    button = new Button("Close Window");
    add(button);
  }
  
  public boolean action(Event evt, Object arg)
  {
      if(arg == "Close Window")
      {
          dispose();
      }
      return true;
  }
  public void paint(Graphics g)
  {
    resize(200,100);
    g.drawString("This is a custom window ", 40,60);
  }
}
// This is only for appletviewer execution.
// <APPLET CODE="FrameExampleApplet3.class" HEIGHT="400" WIDTH="400">Your browser is not applet capable</APPLET>