/**
 * TitleScreen.java
 * 
 * Class representing the opening screen of the simulation interface.
 * 
 * @author Willy McHie
 * Wheaton College, CSCI 335, Spring 2013
 */

package edu.wheaton.simulator.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

public class TitleScreen extends Screen {

	private static final long serialVersionUID = 4901621402376078633L;

	public TitleScreen(ScreenManager sm) {
		super(sm);
		this.setLayout(new BorderLayout());
		

		JPanel panel1 = new JPanel();
		JPanel panel2 = new JPanel();

		
		initLabel();
		initMainPanel(panel1,panel2);
		initButton(panel1,"New Simulation", "New Simulation");
		initButton(panel2,"Load a saved Simulation", "Load Existing");
		
		// Since serialization is not yet implemented.
		panel2.getComponent(0).setEnabled(false);
		this.setVisible(true);

	}
	
	private void initLabel(){
		JLabel label = makeLabelPreferredSize("Welcome to the Simulator!",300,150);
		label.setHorizontalAlignment(SwingConstants.CENTER);
		this.add(label, BorderLayout.NORTH);
	}
	
	private void initMainPanel(JPanel panel1, JPanel panel2){
		JPanel mainPanel = makeBoxPanel(BoxLayout.Y_AXIS);
		mainPanel.add(Box.createVerticalGlue());
		mainPanel.add(panel1);
		mainPanel.add(panel2);
		mainPanel.add(Box.createVerticalGlue());
		this.add(mainPanel, BorderLayout.CENTER);
	}
	
	private void initButton(JPanel panel, String buttonName, String listenerName){
		JButton button = makeButton(buttonName,new GeneralButtonListener(listenerName, sm));
		button.setAlignmentX(CENTER_ALIGNMENT);
		button.setPreferredSize(new Dimension(200, 70));
		panel.add(button);
	}

	@Override
	public void load() {
		// Nothing to load
	}
}

@@ -270,16 +270,85 @@
 ension;%0D
+%0Aimport java.awt.GridBagConstraints;%0D%0Aimport java.awt.GridBagLayout;%0D
 %0A%0D%0Aimpor
@@ -713,22 +713,23 @@
 out(new 
-Border
+GridBag
 Layout()
@@ -740,151 +740,37 @@
 %09%09%0D%0A
-%0D%0A%09%09JPanel panel1 = new JPanel();%0D%0A%09%09JPanel panel2 = new JPanel();%0D%0A%0D%0A%09%09%0D%0A%09%09initLabel();%0D%0A%09%09initMainPanel(panel1,panel2);%0D%0A%09%09initButton(panel1,
+%09%09initLabel();%0D%0A%09%09initButton(
 %22New
@@ -820,15 +820,8 @@
 ton(
-panel2,
 %22Loa
@@ -918,22 +918,20 @@
 ted.%0D%0A%09%09
-panel2
+this
 .getComp
@@ -936,17 +936,17 @@
 mponent(
-0
+2
 ).setEna
@@ -955,24 +955,28 @@
 ed(false);%0D%0A
+%09%09%0D%0A
 %09%09this.setVi
@@ -989,18 +989,16 @@
 true);%0D%0A
-%0D%0A
 %09%7D%0D%0A%09%0D%0A%09
@@ -1030,45 +1030,181 @@
 %0D%0A%09%09
-JLabel label = makeLabelPreferredSize
+GridBagConstraints c = new GridBagConstraints();%0D%0A%09%09c.fill = GridBagConstraints.HORIZONTAL;%0D%0A%09%09c.ipady = 50;%0D%0A%09%09c.gridx = 0;%0D%0A%09%09c.gridy = 0;%0D%0A%09%09%0D%0A%09%09JLabel label = new JLabel
 (%22We
@@ -1231,16 +1231,8 @@
 or!%22
-,300,150
 );%0D%0A
@@ -1309,26 +1309,9 @@
 el, 
-BorderLayout.NORTH
+c
 );%0D%0A
@@ -1339,375 +1339,212 @@
 init
-MainPanel(JPanel panel1, JPanel panel2)%7B%0D%0A%09%09JPanel mainPanel = makeBoxPanel(BoxLayout.Y_AXIS);%0D%0A%09%09mainPanel.add(Box.createVerticalGlue());%0D%0A%09%09mainPanel.add(panel1);%0D%0A%09%09mainPanel.add(panel2);%0D%0A%09%09mainPanel.add(Box.createVerticalGlue());%0D%0A%09%09this.add(mainPanel, BorderLayout.CENTER);%0D%0A%09%7D%0D%0A%09%0D%0A%09private void initButton(JPanel panel, String buttonName, S
+Button(String buttonName, String listenerName)%7B%0D%0A%09%09GridBagConstraints c = new GridBagConstraints();%0D%0A%09%09c.fill = GridBagConstraints.HORIZONTAL;%0D%0A%09%09c.gridx = 0;%0D%0A%09%09c.gridy = GridBagCons
 tr
+a
 in
-g listenerName)%7B
+ts.RELATIVE;%0D%0A%09%09
 %0D%0A%09%09
@@ -1668,24 +1668,74 @@
 LIGNMENT);%0D%0A
+%09%09button.setMinimumSize(new Dimension(200, 70));%0D%0A
 %09%09button.set
@@ -1780,13 +1780,12 @@
 %0D%0A%09%09
-panel
+this
 .add
@@ -1791,16 +1791,19 @@
 d(button
+, c
 );%0D%0A%09%7D%0D%0A

Change Title screen to GridBag