

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

// THIS IS A VERY SIMPLE APPLET

public class SampleGUI extends Applet {

   private Dimension size;

   // declare the components of the gui
   private Button press_me;
   private MyCanvas pic;

   // Constructor is for instantiating the components
   //
   public SampleGUI () {
      size = new Dimension(600,400);

      // instantiate the components.
      press_me = new Button("Press me!");
      pic = new MyCanvas();
   }

   // init() is for adding the components to the applet
   //
   public void init() {

      // add the components to the applet

      add(press_me);
      add(pic);
      
      resize (size);
   }
}

// This is a simple canvas.  A rectangle with an 'X' through it. 
class MyCanvas extends Canvas {

   Dimension size;
      
   public MyCanvas() {
      size = new Dimension(100,100);
      resize(size);
      
   }

   // draw the image
   //
   public void paint(Graphics page) {
      page.drawRect(0,0,size.width-1,size.height-1);
      page.drawLine(0,0,size.width-1,size.height-1);
      page.drawLine(0,size.height-1,size.width-1,0);
   }

   // the next two methods are required for the canvas to work
   public Dimension getMinimumSize() {
      return size;
   }
   public Dimension getPreferredSize() {
      return getMinimumSize();
   }
}


