gt: 			this.menu = new GameMenu(this, false, false);
context: /**
   *	Version 1.00
   *	Copyright (C) 2009 Ivo Wetzel
   *	<http://code.google.com/p/bonsaigamelibrary/>
   *
   *
   *  This file is part of the Bonsai Game Library.
   *
   *  The Bonsai Game Library is free software: you can redistribute it and/or 
   *  modify it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation, either version 3 of the License, or
   *  (at your option) any later version.
   *
   *  The Bonsai Game Library is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details.
   * 
   *  You should have received a copy of the GNU General Public License along with
   *  the Bonsai Game Library. If not, see <http://www.gnu.org/licenses/>.
   *  
   */
  
  package org.bonsai.dev;
  
  import java.applet.Applet;
  import java.awt.BorderLayout;
  import java.awt.Canvas;
  import java.awt.Color;
  import java.awt.Container;
  import java.awt.Graphics2D;
  import java.awt.GraphicsConfiguration;
  import java.awt.GraphicsEnvironment;
  import java.awt.Toolkit;
  import java.awt.event.WindowAdapter;
  import java.awt.event.WindowEvent;
  import java.awt.image.BufferStrategy;
  import java.awt.image.BufferedImage;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.net.URISyntaxException;
  
  import javax.swing.JFrame;
  import javax.swing.WindowConstants;
  
  import org.bonsai.ext.Base64;
  
  import netscape.javascript.JSObject;
  
  public class Game extends Applet {
  	// Applet
  	private static final long serialVersionUID = -7860545086276629929L;
  
  	// Graphics
  	private GraphicsConfiguration config =
  			GraphicsEnvironment.getLocalGraphicsEnvironment()
  				.getDefaultScreenDevice()
  				.getDefaultConfiguration();
  
  	private Canvas canvas;
  	private BufferStrategy strategy;
  	private BufferedImage background;
  	private Graphics2D graphics;
  	private Graphics2D backgroundGraphics;
  	private int width;
  	private int height;
  	private int scale;
  
  	// Game Stuff
  	private boolean gameLoaded = false;
  	private boolean gameSound = false;
  	private boolean isRunning = true;
  	protected boolean paused = false;
  	private boolean focused = false;
  	private boolean pausedOnFocus = false;
  	private boolean animationPaused = false;
  
  	private int currentFPS = 0;
  	private long fpsWait;
  	private long gameTime = 0;
  	private boolean limitFPS = true;
  
  	private boolean stopped = false;
  	private transient Thread gameLoader = null;
  
  	// GUI
  	private JFrame frame = null;
  	private Applet applet = null;
  
  	// Classes
  	protected GameAnimation animation = null;
  	protected GameSound sound = null;
  	protected GameImage image = null;
  	protected GameInput input = null;
  	protected GameFont font = null;
  	protected GameTimer timer = null;
  	protected GameMenu menu = null;
  	
  	// Console
  	protected GameConsole console = null;
  	protected boolean consoleOpen = false;
  
  	/*
  	 * Path --------------------------------------------------------------------
  	 */
  	public final boolean isJar() {
  		boolean isJar = true;
  		if (!isApplet()) {
  			isJar = currentPath().toLowerCase().endsWith(".jar");
  		}
  		return isJar;
  	}
  
  	public final String getPath() {
  		String path = "";
  		if (!isApplet()) {
  			path = currentPath();
  			if (isJar()) {
  				path = path.substring(0, path.lastIndexOf("/") + 1);
  			}
  		}
  		return path;
  	}
  
  	private String currentPath() {
  		String path = "";
  		if (!isApplet()) {
  			try {
  				path =
  						this.getClass()
  							.getProtectionDomain()
  							.getCodeSource()
  							.getLocation()
  							.toURI()
  							.getPath();
  			} catch (URISyntaxException e) {
  				path = "";
  			}
  		}
  		return path;
  	}
  
  	/*
  	 * GUI ---------------------------------------------------------------------
  	 */
  	public final void frame(final String title, final int sizex,
  			final int sizey, final boolean scaled, final boolean initMenu,
  			final boolean gameMenu, final boolean gameConsole) {
  
  		// Size
  		if (scaled) {
  			scale = 2;
  		} else {
  			scale = 1;
  		}
  		width = sizex;
  		height = sizey;
  
  		// Create frame
  		frame = new JFrame(config);
  		frame.setLayout(new BorderLayout(0, 0));
  		frame.setResizable(false);
  		frame.setTitle(title);
  		menu = new GameMenu(this, initMenu, gameMenu);
  		frame.addWindowListener(new FrameClose());
  		frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
  		frame.setVisible(true);
  
  		
  		// Engine
  		resizeFrame();
  		initEngine(frame);
  		if (gameConsole) {
  			console = new GameConsole(this, width(), height() / 4);
  		}
  
  		initThreads();
  		canvas.requestFocus();
  	}
  
  	public void setSize(final int width, final int height) {
  		this.width = width;
  		this.height = height;
  		background = image.create(width, height, false);
  		backgroundGraphics = (Graphics2D) background.getGraphics();
  		setScale(1);
  	}
  
  	public void resizeFrame() {
  		frame.setSize((width * scale) + frame.getInsets().left
  				+ frame.getInsets().right, (height * scale)
  				+ frame.getInsets().top + frame.getInsets().bottom
  				+ menu.getSize());
  	}
  
  	public void onMenu(final String menuID) {
  	}
  	
  	public void onConsole(final String consoleInput) {
  		
  	}
  
  	private class FrameClose extends WindowAdapter {
  		@Override
  		public void windowClosing(final WindowEvent e) {
  			isRunning = false;
  		}
  	}
  
  	public final JFrame getFrame() {
  		return frame;
  	}
  
  	public final boolean hasMenu() {
  		return menu != null;
  	}
  
  	public static void main(final String args[]) {
  		new Game().frame("Bonsai Game Library 1.00", 320, 240, false, true,
  				true, true);
  	}
  
  	/*
  	 * Applet ------------------------------------------------------------------
  	 */
  
  	@Override
  	public final void init() {
  		if (stopped) {
  			isRunning = true;
  		} else {
  			scale = getParameter("scaled") != null ? 2 : 1;
  			width = getWidth() / scale;
  			height = getHeight() / scale;
  			setLayout(null);
  