big update
This commit is contained in:
BIN
DEV.3.1/TP/TP4/ex1/build/GFenetre.class
Normal file
BIN
DEV.3.1/TP/TP4/ex1/build/GFenetre.class
Normal file
Binary file not shown.
BIN
DEV.3.1/TP/TP4/ex1/build/GestionSouris.class
Normal file
BIN
DEV.3.1/TP/TP4/ex1/build/GestionSouris.class
Normal file
Binary file not shown.
BIN
DEV.3.1/TP/TP4/ex1/build/Main.class
Normal file
BIN
DEV.3.1/TP/TP4/ex1/build/Main.class
Normal file
Binary file not shown.
BIN
DEV.3.1/TP/TP4/ex1/galerie.jar
Normal file
BIN
DEV.3.1/TP/TP4/ex1/galerie.jar
Normal file
Binary file not shown.
BIN
DEV.3.1/TP/TP4/ex1/res/MICHEL.gif
Normal file
BIN
DEV.3.1/TP/TP4/ex1/res/MICHEL.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 MiB |
BIN
DEV.3.1/TP/TP4/ex1/res/imag2.jpeg
Normal file
BIN
DEV.3.1/TP/TP4/ex1/res/imag2.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
DEV.3.1/TP/TP4/ex1/res/image1.jpeg
Normal file
BIN
DEV.3.1/TP/TP4/ex1/res/image1.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
21
DEV.3.1/TP/TP4/ex1/src/GFenetre.java
Normal file
21
DEV.3.1/TP/TP4/ex1/src/GFenetre.java
Normal file
@@ -0,0 +1,21 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class GFenetre extends JFrame {
|
||||
|
||||
public GFenetre() {
|
||||
super("Galerie");
|
||||
this.setSize(1000, 600);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLayout(new GridLayout(1,1));
|
||||
|
||||
JLabel imgJLabel = new JLabel(new ImageIcon("../res/MICHEL.gif"));
|
||||
this.add(imgJLabel, BorderLayout.CENTER);
|
||||
|
||||
this.add(imgJLabel);
|
||||
this.addMouseListener(new GestionSouris(imgJLabel ,this));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
52
DEV.3.1/TP/TP4/ex1/src/GestionSouris.java
Normal file
52
DEV.3.1/TP/TP4/ex1/src/GestionSouris.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 GestionSouris implements MouseListener {
|
||||
|
||||
private JLabel img;
|
||||
private String[] images;
|
||||
private int actuel;
|
||||
private GFenetre gfenetre;
|
||||
|
||||
public GestionSouris(JLabel img, GFenetre gfenetre) {
|
||||
this.img = img;
|
||||
this.gfenetre = gfenetre;
|
||||
String[] temp = {
|
||||
"../res/MICHEL.gif",
|
||||
"../res/image1.jpeg",
|
||||
"../res/imag2.jpeg"
|
||||
};
|
||||
|
||||
this.images = temp;
|
||||
this.actuel = 0;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent evenement) {
|
||||
if (evenement.getX() < this.gfenetre.getWidth()/2) {
|
||||
this.actuel--;
|
||||
if (this.actuel == -1) {
|
||||
this.actuel = 3;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.actuel++;
|
||||
if (this.actuel == 4) {
|
||||
this.actuel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.gfenetre.getContentPane().removeAll();
|
||||
this.gfenetre.add(new JLabel(new ImageIcon(this.images[this.actuel])));
|
||||
this.gfenetre.revalidate();
|
||||
this.gfenetre.repaint();
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {}
|
||||
public void mouseReleased(MouseEvent e) {}
|
||||
public void mouseEntered(MouseEvent e) {}
|
||||
public void mouseExited(MouseEvent e) {}
|
||||
}
|
10
DEV.3.1/TP/TP4/ex1/src/Main.java
Normal file
10
DEV.3.1/TP/TP4/ex1/src/Main.java
Normal file
@@ -0,0 +1,10 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
GFenetre fenetre = new GFenetre();
|
||||
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
BIN
DEV.3.1/TP/TP4/ex1_test/build/GFenetre.class
Normal file
BIN
DEV.3.1/TP/TP4/ex1_test/build/GFenetre.class
Normal file
Binary file not shown.
BIN
DEV.3.1/TP/TP4/ex1_test/build/GestionSouris.class
Normal file
BIN
DEV.3.1/TP/TP4/ex1_test/build/GestionSouris.class
Normal file
Binary file not shown.
BIN
DEV.3.1/TP/TP4/ex1_test/build/Main.class
Normal file
BIN
DEV.3.1/TP/TP4/ex1_test/build/Main.class
Normal file
Binary file not shown.
BIN
DEV.3.1/TP/TP4/ex1_test/res/MICHEL.gif
Normal file
BIN
DEV.3.1/TP/TP4/ex1_test/res/MICHEL.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 MiB |
BIN
DEV.3.1/TP/TP4/ex1_test/res/imag2.jpeg
Normal file
BIN
DEV.3.1/TP/TP4/ex1_test/res/imag2.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
DEV.3.1/TP/TP4/ex1_test/res/image1.jpeg
Normal file
BIN
DEV.3.1/TP/TP4/ex1_test/res/image1.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
35
DEV.3.1/TP/TP4/ex1_test/src/Controlleur.java
Normal file
35
DEV.3.1/TP/TP4/ex1_test/src/Controlleur.java
Normal file
@@ -0,0 +1,35 @@
|
||||
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 int actuel;
|
||||
private CardLayout layout;
|
||||
|
||||
public Controlleur(JLabel[] img, Fenetre fenetre, CardLayout layout) {
|
||||
this.img = img;
|
||||
this.fenetre = fenetre;
|
||||
this.actuel = 0;
|
||||
this.layout = layout;
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent evenement) {
|
||||
if (evenement.getX() < this.fenetre.getWidth()/2) {
|
||||
this.layout.previous(this.fenetre.getContentPane());
|
||||
}
|
||||
else {
|
||||
this.layout.next(this.fenetre.getContentPane());
|
||||
}
|
||||
this.layout.show(this.fenetre.getContentPane(), "wow");
|
||||
} // 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é
|
||||
}
|
27
DEV.3.1/TP/TP4/ex1_test/src/Fenetre.java
Normal file
27
DEV.3.1/TP/TP4/ex1_test/src/Fenetre.java
Normal file
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
|
||||
CardLayout layout = new CardLayout();
|
||||
this.setLayout(layout);
|
||||
|
||||
JLabel img1 = new JLabel(new ImageIcon("img1.jpg"));
|
||||
JLabel img2 = new JLabel(new ImageIcon("img2.jpg"));
|
||||
JLabel img3 = new JLabel(new ImageIcon("img3.jpg"));
|
||||
JLabel img4 = new JLabel(new ImageIcon("img4.jpg"));
|
||||
|
||||
JLabel[] tableau = {img1, img2, img3, img4};
|
||||
|
||||
this.add(img1);
|
||||
this.add(img2);
|
||||
this.add(img3);
|
||||
this.add(img4);
|
||||
this.addMouseListener(new Controlleur(tableau, this, layout));
|
||||
}
|
||||
}
|
6
DEV.3.1/TP/TP4/ex1_test/src/Main.java
Normal file
6
DEV.3.1/TP/TP4/ex1_test/src/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user