tp3
This commit is contained in:
parent
4d7c490f87
commit
ee94179c71
Binary file not shown.
@ -4,7 +4,7 @@ import java.awt.event.*;
|
|||||||
import java.lang.*;
|
import java.lang.*;
|
||||||
|
|
||||||
|
|
||||||
public class Boutons extends JPanel implements WindowListener{
|
public class Boutons extends JPanel{
|
||||||
|
|
||||||
public Boutons() {
|
public Boutons() {
|
||||||
super();
|
super();
|
||||||
@ -72,32 +72,4 @@ public class Boutons extends JPanel implements WindowListener{
|
|||||||
this.add(five, gbc);
|
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){
|
|
||||||
}
|
|
||||||
}
|
}
|
BIN
DEV3.1/TP3:MisesEnPage/Boutons/Fenetre$1.class
Normal file
BIN
DEV3.1/TP3:MisesEnPage/Boutons/Fenetre$1.class
Normal file
Binary file not shown.
BIN
DEV3.1/TP3:MisesEnPage/Boutons/Fenetre.class
Normal file
BIN
DEV3.1/TP3:MisesEnPage/Boutons/Fenetre.class
Normal file
Binary file not shown.
40
DEV3.1/TP3:MisesEnPage/Boutons/Fenetre.java
Normal file
40
DEV3.1/TP3:MisesEnPage/Boutons/Fenetre.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
@ -6,15 +6,10 @@ import java.lang.*;
|
|||||||
|
|
||||||
public class Main{
|
public class Main{
|
||||||
|
|
||||||
static JFrame fenetre = new JFrame();
|
static Fenetre fenetre = new Fenetre();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
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);
|
fenetre.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user