SAE21_2021/Case.java

51 lines
1010 B
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);
2022-05-04 19:53:32 +02:00
this.setBackground(new Color(70, 70, 70));
}
public void setVisible(){
this.visible=true;
2022-05-04 19:53:32 +02:00
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));
}
}
this.updateUI();
}
2022-04-28 16:50:06 +02:00
public boolean getVisible(){
return this.visible;
}
2022-05-04 19:53:32 +02:00
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
}