SAE21_2021/Case.java

42 lines
993 B
Java
Raw Normal View History

2022-04-28 16:50:06 +02:00
import javax.swing.*;
import java.awt.*;
2022-04-28 17:57:18 +02:00
public class Case extends JComponent {
private JPanel panel = new JPanel();
2022-04-29 10:03:05 +02:00
private int entourage;
private boolean visible;
private boolean minee;
2022-04-28 16:50:06 +02:00
2022-04-28 17:57:18 +02:00
public Case(Dimension caseSize, boolean visible, boolean minee, int entourage) {
super();
this.entourage=entourage;
this.visible=visible;
this.minee=minee;
2022-04-29 10:03:05 +02:00
this.panel.setSize(caseSize);
GridLayout unique = new GridLayout(1,1);
this.panel.setLayout(unique);
2022-04-28 16:50:06 +02:00
2022-04-28 17:57:18 +02:00
if (this.visible == false) {
Color gray2 = new Color(70, 70, 70);
this.panel.setBackground(gray2);
} else if (this.visible == true) {
Color gray1 = new Color(80, 80, 80);
this.panel.setBackground(gray1);
if (this.minee == true) {
Color rose = new Color(236, 0, 140);
this.panel.setBackground(rose);
} else if (this.entourage>0){
System.out.println(""+ this.entourage);
2022-04-29 10:03:05 +02:00
this.panel.add(new Chiffre(entourage,caseSize));
2022-04-28 17:57:18 +02:00
}
}
2022-04-28 16:50:06 +02:00
2022-04-28 17:57:18 +02:00
}
public JPanel getCase() {
return this.panel;
}
2022-04-28 16:50:06 +02:00
}