package applets;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;

public class BoxApplet
    extends JApplet {
  boolean isStandalone = false;
  BorderLayout borderLayout1 = new BorderLayout();

  //Get a parameter value
  public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
        (getParameter(key) != null ? getParameter(key) : def);
  }

  //Construct the applet
  public BoxApplet() {
  }
  
  public void paint(Graphics g) {
      drawX(g,20,30,200, 150, 25);
  }
  
  private void drawX(Graphics g, int x, int y, int width, int height, int inset) {
      g.setColor(Color.yellow);
      g.fillRect(x,y,width,height);
      g.setColor(Color.red);
      g.drawRect(x+inset, y+inset, width-2*inset, height-2*inset);
      g.setColor(Color.black);
      g.drawRect(x,y,width,height);
      g.drawLine(x+inset,y+inset,x + width - inset,y + height - inset);
      g.drawLine(x+inset,y+height-inset,x+width - inset, y + inset);
  }

  //Initialize the applet
  public void init() {
    try {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  //Component initialization
  private void jbInit() throws Exception {
    this.setSize(new Dimension(400, 300));
    this.getContentPane().setLayout(borderLayout1);
  }

  //Get Applet information
  public String getAppletInfo() {
    return "Applet Information";
  }

  //Get parameter info
  public String[][] getParameterInfo() {
    return null;
  }

  //static initializer for setting look & feel
  static {
    try {
      //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    }
    catch (Exception e) {
    }
  }
}

