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, String title, int width, int height, boolean useContentSize, boolean resizable, boolean fullscreen, boolean hideCursor) {
		setup(gameWindow, title);
		
		if (useContentSize) {
			setContentSize(width, height);
		} else {
			setSize(width, height);
		}
		
		setResizable(resizable);
		if (fullscreen) {
			setUndecorated(true);
			setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH);
		}
		if (hideCursor) {
			setCursorHidden(true);
		}
	}
	
	public Frame(GameWindow gameWindow, int width, int height, String title) {
		setup(gameWindow, title);
		
		setSize(width, height);
		setResizable(false);
	}
	
	private void setup(GameWindow gameWindow, String title) {
		this.gameWindow = gameWindow;
		add(gameWindow);
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setTitle(title);
	}
	
	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();
	}
}

@@ -310,16 +310,71 @@
 Window;%0A
+%09private int defaultWidth;%0A%09private int defaultHeight;%0A
 %09%0A%09publi
@@ -543,32 +543,47 @@
 ameWindow, title
+, width, height
 );%0A%09%09%0A%09%09if (useC
@@ -972,17 +972,33 @@
 w, title
-)
+, width, height);
 ;%0A%09%09%0A%09%09s
@@ -1103,19 +1103,95 @@
 ng title
-) %7B
+, int width, int height) %7B%0A%09%09defaultWidth = width;%0A%09%09defaultHeight = height;%0A%09%09
 %0A%09%09this.
@@ -1307,24 +1307,462 @@
 itle);%0A%09%7D%0A%09%0A
+%09public void setFullscreen(boolean fullscreen) %7B%0A%09%09if (isUndecorated() == fullscreen) %7B%0A%09%09%09return;%0A%09%09%7D%0A%09%09// Dispose window to decorate%0A%09%09dispose();%0A%09%09setUndecorated(fullscreen);%0A%09%09if (fullscreen) %7B%0A%09%09%09// Set window full screen%0A%09%09%09setExtendedState(getExtendedState() %7C JFrame.MAXIMIZED_BOTH);%0A%09%09%7D else %7B%0A%09%09%09// Set window to defaults%0A%09%09%09setSize(defaultHeight, defaultWidth);%0A%09%09%7D%0A%09%09// Show window%0A%09%09add(gameWindow);%0A%09%09setVisible(true);%0A%09%7D%0A%09%0A
 %09public void

Add setFullscreen to Frame