package fr.monkhanny.dorfromantik.listeners;

import fr.monkhanny.dorfromantik.gui.MainMenu;

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

public class CloseWindowListener extends WindowAdapter {

    private MainMenu mainMenu;
    private JFrame frame;

    public CloseWindowListener(MainMenu mainMenu, JFrame frame) {
        this.mainMenu = mainMenu;
        this.frame = frame;
    }

    @Override
    public void windowClosing(WindowEvent e) {
        // Réafficher la fenêtre du menu principal
        mainMenu.setVisible(true);
        frame.setVisible(false);
    }
}
