SAe/SAe2.1/VuePlateau.java

39 lines
859 B
Java
Raw Normal View History

2023-05-19 17:13:41 +02:00
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.lang.*;
public class VuePlateau extends JPanel{
private VueCase[][] tableauCase;
private int vuePoints;
public VuePlateau(VueCase[][] tabl){
this.tableauCase=tabl;
this.vuePoints=0;
}
public void upPoint(int c){
this.vuePoints += c;
this.repaint();
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics p2 = g.create();
if (this.isOpaque()) {
// obligatoire : on repeint toute la surface avec la couleur de fond
p2.setColor(this.getBackground());
p2.fillRect(0, 0, this.getWidth(), this.getHeight());
}
p2.setColor(Color.BLACK);
p2.drawString("Points :" + this.vuePoints, this.getWidth() - 70, this.getHeight() - 10);
}
public void update(Case nc, int x, int y){
tableauCase[x][y].setCase(nc);
this.repaint();
}
}