import javax.swing.*;
import java.awt.*;

public class PhilosopherApplet extends JApplet {
    private static final int FRAME_WIDTH = 520;
    private static final int FRAME_HEIGHT = 590;
    private static final int GRID_ROWS = 50;
    private static final int GRID_COLUMNS = 50;

    public PhilosopherApplet () {
	JRootPane pane = getRootPane ();

	if (pane != null) {
	    pane.putClientProperty ("defaultSystemEventQueueCheck", Boolean.TRUE);
	}
    }

    public void init () {
	Grid grid = new Grid (GRID_ROWS, GRID_COLUMNS);
	Simulator sim = new Simulator (FRAME_HEIGHT, FRAME_WIDTH, grid);
	Container content = getContentPane ();
	
	// Add classes to the simulation.  
	sim.addClass ("RandomWalker");
	sim.addClass ("DrunkPhilosopher");
	
	if (content != null) {
	    content.add (sim, BorderLayout.CENTER);
	} else {
	    System.err.println ("ERROR: No content pane");
	}
	
	Container pane = getContentPane ();

	if (pane != null) {
	    pane.add (sim, BorderLayout.CENTER);
	}
    }
}