fin TP03
This commit is contained in:
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonNon.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonNon.class
Normal file
Binary file not shown.
18
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonNon.java
Normal file
18
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonNon.java
Normal file
@@ -0,0 +1,18 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
|
||||
public class ControleurBoutonNon implements ActionListener {
|
||||
|
||||
private JDialog fenetre;
|
||||
|
||||
public ControleurBoutonNon(JDialog fenetre) {
|
||||
this.fenetre = fenetre;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
fenetre.dispose();
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonOui.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonOui.class
Normal file
Binary file not shown.
18
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonOui.java
Normal file
18
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonOui.java
Normal file
@@ -0,0 +1,18 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
|
||||
public class ControleurBoutonOui implements ActionListener {
|
||||
|
||||
private JFrame fenetre;
|
||||
|
||||
public ControleurBoutonOui(JFrame fenetre) {
|
||||
this.fenetre = fenetre;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
this.fenetre.dispose();
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurFenetre.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurFenetre.class
Normal file
Binary file not shown.
43
DEV3.1/TP02/02_Confirmation/v1/ControleurFenetre.java
Normal file
43
DEV3.1/TP02/02_Confirmation/v1/ControleurFenetre.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
public class ControleurFenetre implements WindowListener {
|
||||
|
||||
private JFrame fenetre;
|
||||
|
||||
public ControleurFenetre(JFrame fenetre) {
|
||||
this.fenetre = fenetre;
|
||||
}
|
||||
|
||||
|
||||
public void windowClosing(WindowEvent evenement){
|
||||
JDialog fermeture = new JDialog(this.fenetre, "Fermeture");
|
||||
fermeture.setLayout(new BorderLayout());
|
||||
JLabel texte = new JLabel("Voulez-vous vraiment quitter ?");
|
||||
texte.setHorizontalAlignment(JLabel.CENTER);
|
||||
fermeture.add(texte, BorderLayout.CENTER);
|
||||
JPanel panneau = new JPanel();
|
||||
panneau.setLayout(new FlowLayout());
|
||||
JButton oui = new JButton("Oui");
|
||||
oui.addActionListener(new ControleurBoutonOui(this.fenetre));
|
||||
JButton non = new JButton("Non");
|
||||
non.addActionListener(new ControleurBoutonNon(fermeture));
|
||||
panneau.add(oui);
|
||||
panneau.add(non);
|
||||
fermeture.add(panneau, BorderLayout.SOUTH);
|
||||
fermeture.setLocation(400, 275);
|
||||
fermeture.setSize(300, 100);
|
||||
fermeture.setVisible(true);
|
||||
} // avant fermeture
|
||||
|
||||
|
||||
|
||||
public void windowActivated(WindowEvent evenement) {} // premier plan
|
||||
public void windowClosed(WindowEvent evenement){} // après fermeture
|
||||
public void windowDeactivated(WindowEvent evenement){} // arrière-plan
|
||||
public void windowDeiconified(WindowEvent evenement){} // restauration
|
||||
public void windowIconified(WindowEvent evenement){} // minimisation
|
||||
public void windowOpened(WindowEvent evenement){} // après ouverture
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/Controlleur.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/Controlleur.class
Normal file
Binary file not shown.
52
DEV3.1/TP02/02_Confirmation/v1/Controlleur.java
Normal file
52
DEV3.1/TP02/02_Confirmation/v1/Controlleur.java
Normal file
@@ -0,0 +1,52 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Controlleur implements MouseListener {
|
||||
|
||||
private JLabel img;
|
||||
private Fenetre fenetre;
|
||||
private String[] images;
|
||||
private int actuel;
|
||||
|
||||
public Controlleur(JLabel img, Fenetre fenetre) {
|
||||
this.img = img;
|
||||
this.fenetre = fenetre;
|
||||
String[] temp = {
|
||||
"img1.jpg",
|
||||
"img2.jpg",
|
||||
"img3.jpg",
|
||||
"img4.jpg"
|
||||
};
|
||||
|
||||
this.images = temp;
|
||||
this.actuel = 0;
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent evenement) {
|
||||
if (evenement.getX() < this.fenetre.getWidth()/2) {
|
||||
this.actuel--;
|
||||
if (this.actuel == -1) {
|
||||
this.actuel = 3;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.actuel++;
|
||||
if (this.actuel == 4) {
|
||||
this.actuel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.fenetre.getContentPane().removeAll();
|
||||
this.fenetre.add(new JLabel(new ImageIcon(this.images[this.actuel])));
|
||||
this.fenetre.revalidate();
|
||||
this.fenetre.repaint();
|
||||
} // un bouton cliqué
|
||||
|
||||
|
||||
public void mouseEntered(MouseEvent evenement) {} // debut du survol
|
||||
public void mouseExited(MouseEvent evenement) {} // fin du survol
|
||||
public void mousePressed(MouseEvent evenement) {} // un bouton appuyé
|
||||
public void mouseReleased(MouseEvent evenement) {} // un bouton relâché
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/Fenetre.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/Fenetre.class
Normal file
Binary file not shown.
19
DEV3.1/TP02/02_Confirmation/v1/Fenetre.java
Normal file
19
DEV3.1/TP02/02_Confirmation/v1/Fenetre.java
Normal file
@@ -0,0 +1,19 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
public Fenetre() {
|
||||
this.setSize(900, 450);
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
|
||||
this.setLayout(new GridLayout(1, 1));
|
||||
|
||||
JLabel img = new JLabel(new ImageIcon("img1.jpg"));
|
||||
|
||||
this.add(img);
|
||||
this.addMouseListener(new Controlleur(img, this));
|
||||
this.addWindowListener(new ControleurFenetre(this));
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/Main.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/Main.class
Normal file
Binary file not shown.
6
DEV3.1/TP02/02_Confirmation/v1/Main.java
Normal file
6
DEV3.1/TP02/02_Confirmation/v1/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/img1.jpg
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/img1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 83 KiB |
BIN
DEV3.1/TP02/02_Confirmation/v1/img2.jpg
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/img2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
BIN
DEV3.1/TP02/02_Confirmation/v1/img3.jpg
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/img3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 200 KiB |
BIN
DEV3.1/TP02/02_Confirmation/v1/img4.jpg
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/img4.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 127 KiB |
Reference in New Issue
Block a user