2022-04-30 16:38:56 +02:00
|
|
|
import java.awt.event.*;
|
|
|
|
import java.awt.*;
|
|
|
|
|
|
|
|
public class Listener implements MouseListener{
|
2022-05-03 15:32:40 +02:00
|
|
|
private int marquage=0;
|
2022-04-30 16:38:56 +02:00
|
|
|
|
|
|
|
@Override
|
2022-05-01 13:41:44 +02:00
|
|
|
public void mouseClicked(MouseEvent evenement){
|
|
|
|
Case panel = (Case)evenement.getSource();
|
2022-05-03 15:32:40 +02:00
|
|
|
if ((evenement.getButton() == MouseEvent.BUTTON1)&&(panel.getVisible()==false)&&(this.marquage==0)){
|
2022-05-01 13:41:44 +02:00
|
|
|
panel.setVisible();
|
|
|
|
panel.getCase();
|
|
|
|
if (panel.getMine()==true){
|
|
|
|
System.out.println("Perdu!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (evenement.getButton() == MouseEvent.BUTTON3) {
|
2022-05-03 15:32:40 +02:00
|
|
|
if (this.marquage==0){
|
|
|
|
panel.add(new Etoile(panel.getSize()), BorderLayout.CENTER);
|
|
|
|
this.marquage=1;
|
|
|
|
}
|
|
|
|
else if (this.marquage==1){
|
|
|
|
panel.removeAll();
|
|
|
|
panel.add(new Sus(panel.getSize()), BorderLayout.CENTER);
|
|
|
|
this.marquage=2;
|
|
|
|
}
|
|
|
|
else if (this.marquage==2){
|
|
|
|
panel.removeAll();
|
|
|
|
this.marquage=0;
|
|
|
|
}
|
2022-05-01 13:41:44 +02:00
|
|
|
panel.updateUI();
|
2022-05-03 15:32:40 +02:00
|
|
|
|
|
|
|
System.out.println(""+this.marquage);
|
2022-05-01 13:41:44 +02:00
|
|
|
}
|
2022-04-30 16:38:56 +02:00
|
|
|
}
|
|
|
|
public void mouseEntered(MouseEvent evenement){
|
2022-05-01 13:41:44 +02:00
|
|
|
// System.out.println("mouseEntered");
|
2022-04-30 16:38:56 +02:00
|
|
|
}
|
|
|
|
public void mouseExited(MouseEvent evenement){
|
2022-05-01 13:41:44 +02:00
|
|
|
// System.out.println("mouseExited");
|
2022-04-30 16:38:56 +02:00
|
|
|
}
|
|
|
|
public void mousePressed(MouseEvent evenement){
|
2022-05-01 13:41:44 +02:00
|
|
|
// System.out.println("mousePressed");
|
2022-04-30 16:38:56 +02:00
|
|
|
}
|
|
|
|
public void mouseReleased(MouseEvent evenement){
|
2022-05-01 13:41:44 +02:00
|
|
|
// System.out.println("mouseReleased");
|
2022-04-30 16:38:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|