Voila, j'ai branché un exitListener sur ma frame, pour demander à l'utilisateur une confirmation de sortie, problème, même quand il répond NON, le programme quitte quand même.
Voici le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
 
public class Intro extends JFrame implements ActionListener{
 
	protected JPanel pIntro,intro;
	protected JPanel pManu,pAuto,p1,p2;
	protected JButton auto,manu;
	protected JLabel lfond ; 
	protected URL urlfond;
	protected ImageIcon fond;
 
	public Intro(boolean premiereExecution){
		super();
 
[...]
 
 
	manu.addActionListener(this); 
	auto.addActionListener(this);
 
	setVisible(true);
	pack();
	addWindowListener(new ExitListener());
	setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
	validate();
 
 
class ExitListener extends WindowAdapter {
	  public void windowClosing(WindowEvent event) {
		  int reponse = JOptionPane.showConfirmDialog(null,"Etes vous sur de vouloir quitter le programme ?","Confirmation de sortie",JOptionPane.YES_NO_OPTION);
			if(reponse==0) 
			{
				System.exit(0);
			}
	  }
	}