big update
This commit is contained in:
BIN
DEV.3.1/TP/TP2/Galerie.1/1./GFenetre.class
Normal file
BIN
DEV.3.1/TP/TP2/Galerie.1/1./GFenetre.class
Normal file
Binary file not shown.
19
DEV.3.1/TP/TP2/Galerie.1/1./GFenetre.java
Normal file
19
DEV.3.1/TP/TP2/Galerie.1/1./GFenetre.java
Normal file
@@ -0,0 +1,19 @@
|
||||
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("MICHEL.gif"));
|
||||
this.add(imgJLabel, BorderLayout.CENTER);
|
||||
|
||||
this.add(imgJLabel);
|
||||
this.addMouseListener(new GestionSouris(imgJLabel ,this));
|
||||
|
||||
}
|
||||
}
|
BIN
DEV.3.1/TP/TP2/Galerie.1/1./GestionSouris.class
Normal file
BIN
DEV.3.1/TP/TP2/Galerie.1/1./GestionSouris.class
Normal file
Binary file not shown.
52
DEV.3.1/TP/TP2/Galerie.1/1./GestionSouris.java
Normal file
52
DEV.3.1/TP/TP2/Galerie.1/1./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 = {
|
||||
"MICHEL.gif",
|
||||
"image1.jpeg",
|
||||
"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) {}
|
||||
}
|
BIN
DEV.3.1/TP/TP2/Galerie.1/1./MICHEL.gif
Normal file
BIN
DEV.3.1/TP/TP2/Galerie.1/1./MICHEL.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 MiB |
BIN
DEV.3.1/TP/TP2/Galerie.1/1./Main.class
Normal file
BIN
DEV.3.1/TP/TP2/Galerie.1/1./Main.class
Normal file
Binary file not shown.
@@ -3,10 +3,6 @@ import javax.swing.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
ImageIcon[] images = {new ImageIcon("image1.jpeg"), new ImageIcon("image2.jpeg"), new ImageIcon("MICHEL.gif")};
|
||||
|
||||
GModel model = new GModel(images);
|
||||
GFenetre fenetre = new GFenetre();
|
||||
|
||||
fenetre.setVisible(true);
|
BIN
DEV.3.1/TP/TP2/Galerie.1/1./imag2.jpeg
Normal file
BIN
DEV.3.1/TP/TP2/Galerie.1/1./imag2.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
DEV.3.1/TP/TP2/Galerie.1/1./image1.jpeg
Normal file
BIN
DEV.3.1/TP/TP2/Galerie.1/1./image1.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
0
DEV.3.1/TP/TP2/Galerie.1/2.CardLayout/GFenetre.java
Normal file
0
DEV.3.1/TP/TP2/Galerie.1/2.CardLayout/GFenetre.java
Normal file
0
DEV.3.1/TP/TP2/Galerie.1/2.CardLayout/Gsouris.java
Normal file
0
DEV.3.1/TP/TP2/Galerie.1/2.CardLayout/Gsouris.java
Normal file
0
DEV.3.1/TP/TP2/Galerie.1/2.CardLayout/Main.java
Normal file
0
DEV.3.1/TP/TP2/Galerie.1/2.CardLayout/Main.java
Normal file
@@ -1,26 +0,0 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class GFenetre extends JFrame {
|
||||
private JLabel imgJLabel;
|
||||
|
||||
public GFenetre() {
|
||||
super("Galerie");
|
||||
this.setSize(1000, 600);
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
this.imgJLabel = new JLabel();
|
||||
this.add(this.imgJLabel, BorderLayout.CENTER);
|
||||
|
||||
}
|
||||
|
||||
public void afficherImage(ImageIcon image) {
|
||||
this.imgJLabel.setIcon(image);
|
||||
}
|
||||
|
||||
public JLabel getImageLabel() {
|
||||
return this.imgJLabel;
|
||||
}
|
||||
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
import javax.swing.*;
|
||||
|
||||
public class GModel {
|
||||
private ImageIcon[] imgCarousel;
|
||||
private int index;
|
||||
|
||||
public GModel(ImageIcon[] imgCarousel) {
|
||||
this.imgCarousel = imgCarousel;
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
public ImageIcon getImageActuel() {
|
||||
return this.imgCarousel[this.index];
|
||||
}
|
||||
|
||||
public void imageSuivante() {
|
||||
this.index = (this.index + 1) % imgCarousel.length;
|
||||
}
|
||||
|
||||
public void imagePrecedente() {
|
||||
this.index = (this.index - 1 + this.imgCarousel.length) % imgCarousel.length;
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class GestionSouris implements MouseListener {
|
||||
|
||||
private GModel model;
|
||||
private GFenetre gfenetre;
|
||||
|
||||
public GestionSouris(GModel model, GFenetre gfenetre) {
|
||||
this.model = model;
|
||||
this.gfenetre = gfenetre;
|
||||
this.gfenetre.getImageLabel().addMouseListener(this);
|
||||
this.gfenetre.afficherImage(this.model.getImageActuel());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int width = this.gfenetre.getImageLabel().getWidth();
|
||||
|
||||
if(x < width / 2) {
|
||||
this.model.imagePrecedente();
|
||||
} else {
|
||||
this.model.imageSuivante();
|
||||
}
|
||||
|
||||
this.gfenetre.remove(this.gfenetre.getImageLabel());
|
||||
this.gfenetre.getImageLabel().setIcon(this.model.getImageActuel());
|
||||
this.gfenetre.add(this.gfenetre.getImageLabel(), BorderLayout.CENTER);
|
||||
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) {}
|
||||
}
|
Reference in New Issue
Block a user