ajout tp4
BIN
DEV3.1/TP04/01_Galerie/build/fr/iutfbleau/galerie/Fenetre.class
Normal file
BIN
DEV3.1/TP04/01_Galerie/build/fr/iutfbleau/galerie/Main.class
Normal file
BIN
DEV3.1/TP04/01_Galerie/build/res/img1.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
DEV3.1/TP04/01_Galerie/build/res/img2.jpg
Normal file
After Width: | Height: | Size: 72 KiB |
BIN
DEV3.1/TP04/01_Galerie/build/res/img3.jpg
Normal file
After Width: | Height: | Size: 200 KiB |
BIN
DEV3.1/TP04/01_Galerie/build/res/img4.jpg
Normal file
After Width: | Height: | Size: 127 KiB |
BIN
DEV3.1/TP04/01_Galerie/galerie.jar
Normal file
BIN
DEV3.1/TP04/01_Galerie/res/img1.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
DEV3.1/TP04/01_Galerie/res/img2.jpg
Normal file
After Width: | Height: | Size: 72 KiB |
BIN
DEV3.1/TP04/01_Galerie/res/img3.jpg
Normal file
After Width: | Height: | Size: 200 KiB |
BIN
DEV3.1/TP04/01_Galerie/res/img4.jpg
Normal file
After Width: | Height: | Size: 127 KiB |
55
DEV3.1/TP04/01_Galerie/src/Controlleur.java
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package fr.iutfbleau.galerie;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class Controlleur implements MouseListener {
|
||||||
|
|
||||||
|
private JLabel img;
|
||||||
|
private Fenetre fenetre;
|
||||||
|
private URL[] images;
|
||||||
|
private int actuel;
|
||||||
|
|
||||||
|
public Controlleur(JLabel img, Fenetre fenetre) {
|
||||||
|
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
|
this.img = img;
|
||||||
|
this.fenetre = fenetre;
|
||||||
|
URL[] temp = {
|
||||||
|
loader.getResource("res/img1.jpg"),
|
||||||
|
loader.getResource("res/img2.jpg"),
|
||||||
|
loader.getResource("res/img3.jpg"),
|
||||||
|
loader.getResource("res/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é
|
||||||
|
}
|
21
DEV3.1/TP04/01_Galerie/src/Fenetre.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package fr.iutfbleau.galerie;
|
||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class Fenetre extends JFrame {
|
||||||
|
|
||||||
|
public Fenetre() {
|
||||||
|
this.setSize(900, 450);
|
||||||
|
this.setLocation(100, 100);
|
||||||
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
this.setLayout(new GridLayout(1, 1));
|
||||||
|
|
||||||
|
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
||||||
|
JLabel img = new JLabel(new ImageIcon(loader.getResource("res/img1.jpg")));
|
||||||
|
|
||||||
|
this.add(img);
|
||||||
|
this.addMouseListener(new Controlleur(img, this));
|
||||||
|
}
|
||||||
|
}
|
8
DEV3.1/TP04/01_Galerie/src/Main.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package fr.iutfbleau.galerie;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Fenetre fenetre = new Fenetre();
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
4
DEV3.1/TP04/01_Galerie/test/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Created-By: 11.0.27 (Arch Linux)
|
||||||
|
Main-Class: fr.iutfbleau.galerie.Main
|
||||||
|
|
BIN
DEV3.1/TP04/01_Galerie/test/fr/iutfbleau/galerie/Fenetre.class
Normal file
BIN
DEV3.1/TP04/01_Galerie/test/fr/iutfbleau/galerie/Main.class
Normal file
BIN
DEV3.1/TP04/01_Galerie/test/galerie.jar
Normal file
BIN
DEV3.1/TP04/01_Galerie/test/img1.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
DEV3.1/TP04/01_Galerie/test/img2.jpg
Normal file
After Width: | Height: | Size: 72 KiB |
BIN
DEV3.1/TP04/01_Galerie/test/img3.jpg
Normal file
After Width: | Height: | Size: 200 KiB |
BIN
DEV3.1/TP04/01_Galerie/test/img4.jpg
Normal file
After Width: | Height: | Size: 127 KiB |