package fr.iutfbleau.projetIHM2022FI2.Permanent.Controller;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
/**
 * l'observateur pour la fermeture de la fenetre
 */
public class ObservateurFenetre implements WindowListener{
		/**
		 * le constructeur
		 */
    public ObservateurFenetre(){

    }
    
    @Override
    public void windowActivated(WindowEvent e) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void windowClosed(WindowEvent e) {
        // TODO Auto-generated method stub
        
    }
		/**
		 * méthode invoquée lors de la fermeture de la fenetre
		 * @param e l'événement
		 */
    @Override
    public void windowClosing(WindowEvent e) {
        JFrame fenetre= (JFrame) e.getSource();
        int confirmation = JOptionPane.showConfirmDialog(fenetre.getContentPane(), "Voulez vous quitter?", "Quitter", JOptionPane.YES_NO_OPTION);
        if(confirmation == JOptionPane.YES_OPTION){
            fenetre.dispose();
        }
    }

    @Override
    public void windowDeactivated(WindowEvent e) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void windowDeiconified(WindowEvent e) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void windowIconified(WindowEvent e) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void windowOpened(WindowEvent e) {
        // TODO Auto-generated method stub
        
    }
    
}
