import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Rectangle;

import javax.swing.JApplet;
import javax.swing.JButton;


public class TestApplet extends JApplet {

	/*
	 	// This code snippet was useful to me though a bit of a hack

		try {
			RuntimeException foo = new RuntimeException();
			foo.setStackTrace(Thread.currentThread().getStackTrace());
			throw foo;
		} catch (Exception e){
			e.printStackTrace();
		}
	 * 
	 */
	
	@Override
	public void init() {
		System.err.println("Test: init called");
	}
	
	@Override
	public void setSize(int width, int height) {
		System.err.println("Test: setSize called.    \t \tw" + width + " \th" + height);
		super.setSize(width, height);
	}
	
	@Override
	public void resize(int width, int height) {
		System.err.println("Test: resize called.     \t \tw" + width + " \th" + height);
		super.resize(width, height);
	}
	
	@Override
	public void setBounds(int x, int y, int width, int height) {
		System.err.println("Test: setBounds called. x" + x + " \ty" + y + " \tw" + width + " \th" + height);
		super.setBounds(x, y, width, height);
	}
	
	@Override
	public void start() {
		System.err.println("Test: start called");
		Container pane = this.getContentPane();
		pane.setLayout(new FlowLayout());
		
		pane.add(new JButton("Test!"));
		
		System.err.println("Test: start exited");
	}
	
	
	@Override
	public void stop() {
		System.err.println("Test: Applet stop called");
	}
	
	// Paint a border to make it obvious where the clipping is 
	@Override
	public void paint(Graphics g) {
		super.paint(g);
		
		Rectangle b = this.getBounds();
		g.drawRect(1, 1, b.width -2, b.height -2);
	}
	
	public void log(String msg) {
		System.err.println(msg);
	}
}
