wow le tp là

This commit is contained in:
Simoes Lukas
2025-09-04 15:36:55 +02:00
parent c16ef0985f
commit 2c3e150ec5
87 changed files with 1059 additions and 28 deletions

Binary file not shown.

View 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é
}

Binary file not shown.

View File

@@ -0,0 +1,18 @@
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));
JLabel img = new JLabel(new ImageIcon("img1.jpg"));
this.add(img);
this.addMouseListener(new Controlleur(img, this));
}
}

Binary file not shown.

View File

@@ -0,0 +1,6 @@
public class Main {
public static void main(String[] args) {
Fenetre fenetre = new Fenetre();
fenetre.setVisible(true);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB