diff --git a/DEV3.1/TP3:MisesEnPage/Boutons/Boutons.class b/DEV3.1/TP3:MisesEnPage/Boutons/Boutons.class index e012ebb..79d7a36 100644 Binary files a/DEV3.1/TP3:MisesEnPage/Boutons/Boutons.class and b/DEV3.1/TP3:MisesEnPage/Boutons/Boutons.class differ diff --git a/DEV3.1/TP3:MisesEnPage/Boutons/Boutons.java b/DEV3.1/TP3:MisesEnPage/Boutons/Boutons.java index 9fe145b..add9762 100644 --- a/DEV3.1/TP3:MisesEnPage/Boutons/Boutons.java +++ b/DEV3.1/TP3:MisesEnPage/Boutons/Boutons.java @@ -4,7 +4,7 @@ import java.awt.event.*; import java.lang.*; -public class Boutons extends JPanel implements WindowListener{ +public class Boutons extends JPanel{ public Boutons() { super(); @@ -72,32 +72,4 @@ public class Boutons extends JPanel implements WindowListener{ this.add(five, gbc); } - - public void windowDeactivated(WindowEvent evenement){ - } - - public void windowActivated(WindowEvent evenement){ - } - - public void windowClosed(WindowEvent evenement){ - } - - public void windowClosing(WindowEvent evenement){ - JOptionPane exit = new JOptionPane(); - int rep = exit.showConfirmDialog(this, "Etes vous certain de vouloir quitter?", "Quitter", JOptionPane.YES_NO_OPTION); - if (rep == JOptionPane.YES_OPTION){ - Main.fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - } else if (rep == JOptionPane.NO_OPTION){ - Main.fenetre.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - } - } - - public void windowDeiconified(WindowEvent evenement){ - } - - public void windowIconified(WindowEvent evenement){ - } - - public void windowOpened(WindowEvent evenement){ - } } \ No newline at end of file diff --git a/DEV3.1/TP3:MisesEnPage/Boutons/Fenetre$1.class b/DEV3.1/TP3:MisesEnPage/Boutons/Fenetre$1.class new file mode 100644 index 0000000..a3599ad Binary files /dev/null and b/DEV3.1/TP3:MisesEnPage/Boutons/Fenetre$1.class differ diff --git a/DEV3.1/TP3:MisesEnPage/Boutons/Fenetre.class b/DEV3.1/TP3:MisesEnPage/Boutons/Fenetre.class new file mode 100644 index 0000000..a2cda6e Binary files /dev/null and b/DEV3.1/TP3:MisesEnPage/Boutons/Fenetre.class differ diff --git a/DEV3.1/TP3:MisesEnPage/Boutons/Fenetre.java b/DEV3.1/TP3:MisesEnPage/Boutons/Fenetre.java new file mode 100644 index 0000000..92be478 --- /dev/null +++ b/DEV3.1/TP3:MisesEnPage/Boutons/Fenetre.java @@ -0,0 +1,40 @@ +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; + } +} \ No newline at end of file diff --git a/DEV3.1/TP3:MisesEnPage/Boutons/Main.class b/DEV3.1/TP3:MisesEnPage/Boutons/Main.class index ba8be3c..13b998c 100644 Binary files a/DEV3.1/TP3:MisesEnPage/Boutons/Main.class and b/DEV3.1/TP3:MisesEnPage/Boutons/Main.class differ diff --git a/DEV3.1/TP3:MisesEnPage/Boutons/Main.java b/DEV3.1/TP3:MisesEnPage/Boutons/Main.java index 043bdfd..7281ce7 100644 --- a/DEV3.1/TP3:MisesEnPage/Boutons/Main.java +++ b/DEV3.1/TP3:MisesEnPage/Boutons/Main.java @@ -6,15 +6,10 @@ import java.lang.*; public class Main{ - static JFrame fenetre = new JFrame(); + static Fenetre fenetre = new Fenetre(); public static void main(String[] args) { - Boutons pan = new Boutons(); - fenetre.setSize(500, 500); - fenetre.setLocation(250, 250); - fenetre.addWindowListener(pan); - fenetre.add(pan); fenetre.setVisible(true); } } \ No newline at end of file