package main.java.gui;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;


public class MainWindow extends JFrame implements ActionListener {

	private GamePanel gamePanel;

	private JMenuBar menuBar;
	private JMenu menuPartie;
	private JMenuItem itemQuitter;
	private JMenuItem itemSauver;
	private JMenuItem itemCharger;
	private JMenuItem itemNouvelle;

	public MainWindow()
	{
		super("Eternity");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setResizable(false);

		this.constructMenu();
		this.gamePanel = new GamePanel();
		// JFrame.add points to JContentPane.add
		// ContentPane has BorderLayout by default
		this.add(this.gamePanel);

		this.setVisible(true);
		this.pack();
	}

	private void constructMenu()
	{
		menuBar = new JMenuBar();
		menuPartie = new JMenu("Partie");


		itemNouvelle = new JMenuItem("Nouvelle partie");
		itemNouvelle.addActionListener(this);

		menuPartie.add(itemNouvelle);
		
		itemSauver = new JMenuItem("Sauvegarder la partie");
		itemSauver.addActionListener(this);

		menuPartie.add(itemSauver);

		itemCharger = new JMenuItem("Charger la partie");
		itemCharger.addActionListener(this);

		menuPartie.add(itemCharger);
		

		itemQuitter = new JMenuItem("Quitter");
		itemQuitter.addActionListener(this);

		menuPartie.add(itemQuitter);
		
		menuBar.add(menuPartie);

		this.setJMenuBar(menuBar);
	}

	public GamePanel getGamePanel() {
		return this.gamePanel;
	}

	/*
	* Events response implementations
	*/

	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource() == (Object)itemQuitter)
			this.dispose();
	}
}

@@ -897,16 +897,36 @@
 nu()%0A%09%7B%0A
+%09%09//Create menu bar%0A
 %09%09menuBa
@@ -945,16 +945,44 @@
 uBar();%0A
+%09%09%0A%09%09//Create menu %22Partie%22%0A
 %09%09menuPa
@@ -1010,17 +1010,16 @@
 tie%22);%0A%0A
-%0A
 %09%09itemNo
@@ -1093,33 +1093,32 @@
 Listener(this);%0A
-%0A
 %09%09menuPartie.add
@@ -1221,33 +1221,32 @@
 Listener(this);%0A
-%0A
 %09%09menuPartie.add
@@ -1343,33 +1343,32 @@
 Listener(this);%0A
-%0A
 %09%09menuPartie.add
@@ -1467,17 +1467,16 @@
 (this);%0A
-%0A
 %09%09menuPa
@@ -1524,25 +1524,24 @@
 enuPartie);%0A
-%0A
 %09%09this.setJM
@@ -1759,16 +1759,16 @@
 uitter)%0A
-
 %09%09%09this.
@@ -1778,13 +1778,369 @@
 pose();%0A
+%09%09if(e.getSource() == (Object)itemNouvelle)%0A%09%09%7B%0A%09%09%09//create new game%0A%09%09%7D%0A%09%09%0A%09%09if(e.getSource() == (Object)itemSauver)%0A%09%09%7B%0A%09%09%09//If save file location unknown, open a dialog for selecting a save file,%0A%09%09%09//Save the game at the save file location%0A%09%09%7D%0A%09%09if(e.getSource() == (Object)itemCharger)%0A%09%09%7B%0A%09%09%09//Open a dialog for selecting a save file and load it%0A%09%09%7D%0A
 %09%7D%0A%7D%0A

Add code for selecting the correct action to perform from the action listener