SAE21_2021/Case.java

56 lines
1.1 KiB
Java
Raw Normal View History

2022-04-28 16:50:06 +02:00
import javax.swing.*;
import java.awt.*;
2022-04-30 16:38:56 +02:00
public class Case extends JPanel {
private Dimension caseSize;
2022-04-29 10:03:05 +02:00
private int entourage;
private boolean visible;
private boolean minee;
2022-04-30 16:38:56 +02:00
private Listener listener;
2022-04-28 16:50:06 +02:00
public Case(Dimension caseSize, boolean minee, int entourage) {
2022-04-28 17:57:18 +02:00
super();
this.entourage=entourage;
this.visible=false;
2022-04-28 17:57:18 +02:00
this.minee=minee;
this.caseSize= caseSize;
this.setSize(caseSize);
2022-04-30 16:38:56 +02:00
this.listener = new Listener();
this.addMouseListener(this.listener);
2022-04-29 10:03:05 +02:00
GridLayout unique = new GridLayout(1,1);
this.setLayout(unique);
}
public void setVisible(){
this.visible=true;
this.updateUI();
}
2022-04-28 16:50:06 +02:00
public boolean getVisible(){
return this.visible;
}
public Case getCase(){
2022-04-28 17:57:18 +02:00
if (this.visible == false) {
this.setBackground(new Color(70, 70, 70));
2022-04-28 17:57:18 +02:00
} else if (this.visible == true) {
if (this.minee == true) {
this.setBackground(new Color(236, 0, 140));
} else {
this.setBackground(new Color(80, 80, 80));
if (this.entourage>0){
this.add(new Chiffre(entourage,caseSize));
}
2022-04-28 17:57:18 +02:00
}
}
return this;
2022-04-28 17:57:18 +02:00
}
public boolean getMine(){
return this.minee;
2022-04-28 17:57:18 +02:00
}
2022-04-28 16:50:06 +02:00
}