package com.betato.gamedisplay;

import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;

import javax.swing.JFrame;

public class Frame extends JFrame{
	private static final long serialVersionUID = 1L;
	
	private GameWindow gameWindow;
	
	public Frame(GameWindow gameWindow, int width, int height, String title, boolean resizable, boolean fullscreen, boolean hideCursor) {
		this.gameWindow = gameWindow;
		add(gameWindow);
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setTitle(title);
		
		setSize(width, height);
		setResizable(resizable);
		if (fullscreen) {
			setUndecorated(true);
			setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH);
		}
		if (hideCursor) {
			setCursorHidden(true);
		}
	}
	
	public void setCursorHidden(boolean hideCursor){ 			
		if (hideCursor) { 			
			// Create a new blank cursor
			BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
			Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(
					cursorImg, new Point(0, 0), "blank cursor"); 			
			// Set the cursor
			getContentPane().setCursor(blankCursor);
		} else {
			// Set default cursor
			getContentPane().setCursor(Cursor.getDefaultCursor());
		}
	}
	
	public void setContentSize(int width, int height) {
		// Set content size and pack
		getContentPane().setPreferredSize(new Dimension(width, height));
		pack();
	}
}

@@ -348,16 +348,30 @@
 eWindow,
+ String title,
  int wid
@@ -386,27 +386,37 @@
 height, 
-String titl
+boolean useContentSiz
 e, boole
@@ -477,13 +477,14 @@
 %7B%0A%09%09
-this.
+setup(
 game
@@ -493,117 +493,91 @@
 ndow
- = gameWindow;%0A%09%09add(gameWindow);%0A%09%09%0A%09%09setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A%09%09setTitle(title);%0A%09%09%0A
+, title);%0A%09%09%0A%09%09if (useContentSize) %7B%0A%09%09%09setContentSize(width, height);%0A%09%09%7D else %7B%0A%09
 %09%09se
@@ -598,16 +598,23 @@
 eight);%0A
+%09%09%7D%0A%09%09%0A
 %09%09setRes
@@ -793,32 +793,380 @@
 true);%0A%09%09%7D%0A%09%7D%0A%09%0A
+%09public Frame(GameWindow gameWindow, int width, int height, String title) %7B%0A%09%09setup(gameWindow, title);%0A%09%09%0A%09%09setSize(width, height);%0A%09%09setResizable(false);%0A%09%7D%0A%09%0A%09private void setup(GameWindow gameWindow, String title) %7B%0A%09%09this.gameWindow = gameWindow;%0A%09%09add(gameWindow);%0A%09%09%0A%09%09setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A%09%09setTitle(title);%0A%09%7D%0A%09%0A
 %09public void set

Add option to create frame with content size