package es.ucm.fdi.tp.views.swing.controlpanel;

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

import javax.swing.JButton;
import javax.swing.JPanel;

import es.ucm.fdi.tp.basecode.bgame.control.Controller;

public class ExitPane extends JPanel implements ActionListener {
	
	private static final long serialVersionUID = 967508544579472464L;
	
	private JButton exitButton;
	private JButton restartButton;
	
	private Controller cntrl;
	
	public ExitPane(Controller c) {
		super(new FlowLayout());
		this.cntrl = c;
		
		this.exitButton = new JButton(" Quit ");
		this.exitButton.addActionListener(this);
		this.add(exitButton);
		
		this.restartButton = new JButton(" Restart ");
		this.restartButton.addActionListener(this);
		this.add(restartButton);
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		JButton target = (JButton) e.getSource();
		if(target == this.exitButton) {
			cntrl.stop();
		} else if (target == this.restartButton) {
			cntrl.restart();
		}
	}

}

@@ -70,16 +70,40 @@
 Layout;%0A
+import java.awt.Window;%0A
 import j
@@ -218,24 +218,59 @@
 wing.JPanel;
+%0Aimport javax.swing.SwingUtilities;
 %0A%0Aimport es.
@@ -314,16 +314,61 @@
 troller;
+%0Aimport es.ucm.fdi.tp.views.swing.QuitDialog;
 %0A%0Apublic
@@ -1037,32 +1037,135 @@
 s.exitButton) %7B%0A
+%09%09%09Window parent = SwingUtilities.getWindowAncestor(this);%0A%09%09%09if(new QuitDialog(parent).getValue()) %7B%0A%09
 %09%09%09cntrl.stop();
@@ -1165,16 +1165,21 @@
 stop();%0A
+%09%09%09%7D%0A
 %09%09%7D else

Add confirmation box before exit