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

public class ControleurFenetre implements WindowListener {

	private JFrame fenetre;

	public ControleurFenetre(JFrame fenetre) {
		this.fenetre = fenetre;
	}


	public void windowClosing(WindowEvent evenement){
		JDialog fermeture = new JDialog(this.fenetre, "Fermeture");
		fermeture.setLayout(new BorderLayout());
		JLabel texte = new JLabel("Voulez-vous vraiment quitter ?");
		texte.setHorizontalAlignment(JLabel.CENTER);
		fermeture.add(texte, BorderLayout.CENTER);
		JPanel panneau = new JPanel();
		panneau.setLayout(new FlowLayout());
		JButton oui = new JButton("Oui");
		oui.addActionListener(new ControleurBoutonOui(this.fenetre));
		JButton non = new JButton("Non");
		non.addActionListener(new ControleurBoutonNon(fermeture));
		panneau.add(oui);
		panneau.add(non);
		fermeture.add(panneau, BorderLayout.SOUTH);
		fermeture.setLocation(400, 275);
		fermeture.setSize(300, 100);
		fermeture.setVisible(true);
	}       // avant fermeture



	public void windowActivated(WindowEvent evenement) {}      // premier plan
	public void windowClosed(WindowEvent evenement){}         // après fermeture
	public void windowDeactivated(WindowEvent evenement){}   // arrière-plan
	public void windowDeiconified(WindowEvent evenement){}    // restauration
	public void windowIconified(WindowEvent evenement){}      // minimisation
	public void windowOpened(WindowEvent evenement){}        // après ouverture
}