40 lines
1002 B
Java
40 lines
1002 B
Java
|
import java.awt.*;
|
||
|
import javax.swing.*;
|
||
|
import java.awt.event.*;
|
||
|
import java.util.*;
|
||
|
import java.io.*;
|
||
|
|
||
|
public class Fenetre extends JFrame{
|
||
|
|
||
|
|
||
|
public Fenetre(){
|
||
|
Boutons pan = new Boutons();
|
||
|
this.setSize(450, 450);
|
||
|
this.setLocation(500, 500);
|
||
|
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||
|
this.setContentPane(pan);
|
||
|
|
||
|
addWindowListener(new WindowAdapter()
|
||
|
{
|
||
|
public void windowClosing(WindowEvent e)
|
||
|
{
|
||
|
if(fermerFenetre()==true){
|
||
|
dispose();
|
||
|
System.exit(0);
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
private boolean fermerFenetre() {
|
||
|
JOptionPane option = new JOptionPane("Voulez-vous vraiment quitter ce programme ?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
|
||
|
JDialog confirmation = option.createDialog(this, "Confirmation de fermeture");
|
||
|
|
||
|
confirmation.setSize(400, 120);
|
||
|
confirmation.setVisible(true);
|
||
|
int result = (int) option.getValue();
|
||
|
confirmation.dispose();
|
||
|
return result == JOptionPane.YES_OPTION;
|
||
|
}
|
||
|
}
|