//HORVILLE Ewen Groupe N°4

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

public class FermetureListener implements WindowListener {

    private boolean hasBeenMinimised = false;

    public FermetureListener() {}
    public void windowActivated(WindowEvent evenement) {}
    public void windowClosed(WindowEvent evenement) {}
    public void windowDeactivated(WindowEvent evenement) {}
    public void windowDeiconified(WindowEvent evenement) {}
    public void windowOpened(WindowEvent evenement) {}

    public void windowClosing(WindowEvent evenement) {
        if (hasBeenMinimised) {
            ((JFrame)evenement.getSource()).dispose();
        }
    }

    public void windowIconified(WindowEvent evenement) {
        hasBeenMinimised = true;
    }
}