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

/**
 * This class represents a window where the user can draw mosaics.  The class
 * contains a main program that simply shows such a window on the screen.
 */
public class MosaicDrawFrame extends JFrame {
	
	/**
	 * The main program simply creates and shows a window belonging to this MosaicDrawFrame class.
	 */
	public static void main(String[] args) {
		MosaicDrawFrame frame = new MosaicDrawFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public MosaicDrawFrame() {
		super("Mosaic Draw");
		final MosaicPanel mosaic = new MosaicPanel(50,50,12,12);
		setContentPane(mosaic);
		Controller controller = new Controller(mosaic);
		setJMenuBar(new Menus(controller,false));
		pack();
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		if (getHeight() > screenSize.height - 20 || getWidth() > screenSize.width - 20) { // adjust size, if too big for screen
			int newWidth = Math.min(getWidth(),screenSize.width - 20);
			int newHeight = Math.min(getHeight(), screenSize.height - 20);
			setSize(new Dimension(newWidth, newHeight));
		}
		int top = (screenSize.height - getHeight()) / 2;  // Center the mosaic on the screen.
		int left = (screenSize.width - getWidth()) / 2;
		setLocation(left,top);
	}

}
