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

public class DialogListener implements MouseListener {

    private JDialog d;
    private boolean shouldClose = false;

    public DialogListener(JDialog d) {
        this.d = d;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        Component c = (Component)e.getSource();

        if (c.getName() == "Oui") {
            shouldClose = true;
            d.dispose();
        } else if (c.getName() == "Non") {
            shouldClose = false;
            d.dispose();
        }
    }

    public boolean getShouldClose() {
        return this.shouldClose;
    }

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

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

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

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