import java.awt.*;
import java.net.*;

/**
 *  An applet that displays the applet's code base 
 * and document base
 */
public class Base extends java.applet.Applet {

  protected String codeBase;
  protected String docBase;
  protected Font font = new java.awt.Font("Sans serif", Font.PLAIN, 24);    
  protected int x, y;
  protected int offset = 1;
  protected Dimension d;
  protected String filename = "";

  public void init() {
    // set initial position of the text
    d = getSize();
    x = d.width / 20;
    y = font.getSize();
   }

  public void paint(Graphics g) {
    try {  
     
      g.setFont(font);
      // set the pen color and draw the background
      g.setColor(Color.black);
      g.fillRect(0,0,d.width,d.height);
    
      //get doc base
      URL urlDoc = new URL(getDocumentBase(), "index.html");
      docBase = urlDoc.toString();
    
      //get code base
      URL urlBase = new URL(getCodeBase(), "Base.class");
      codeBase = urlBase.toString();
      
      // set the pen color
      g.setColor(Color.green);
      
      g.drawString("Code base: ", x, y);
      g.drawString(codeBase, x, 2 * y);
               
      // set the pen color, then draw the text
      g.setColor(Color.cyan);
      g.drawString("Document Base: ", x, 3 * y);
      g.drawString(docBase, x, 4 * y);
    } catch (Exception e){ }   
  }

}