52 lines
1.1 KiB
Java
52 lines
1.1 KiB
Java
![]() |
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) {}
|
||
|
}
|