version copilot
This commit is contained in:
@@ -4,29 +4,33 @@ import java.awt.event.*;
|
||||
|
||||
public class GestionSouris implements MouseListener {
|
||||
|
||||
private Component component;
|
||||
private GModel model;
|
||||
private GFenetre gfenetre;
|
||||
|
||||
public GestionSouris(Component component, GFenetre gfenetre) {
|
||||
this.component = component;
|
||||
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 = component.getWidth();
|
||||
int width = this.gfenetre.getImageLabel().getWidth();
|
||||
|
||||
if(x < width / 2) {
|
||||
//Click à gauche de l'écran
|
||||
System.out.println("click gauche");
|
||||
this.gfenetre.change(0);
|
||||
this.model.imagePrecedente();
|
||||
} else {
|
||||
//Click à droite de l'écran
|
||||
System.out.println("Click droit");
|
||||
this.gfenetre.change(1);
|
||||
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) {}
|
||||
|
Reference in New Issue
Block a user