SAE21_2022/FenetreVideGrille.java

55 lines
1.6 KiB
Java

import java.awt.*;
public class FenetreVideGrille extends Fenetre{
public static final int COULOIR=0;
public static final int MUR=1;
public static final int ENTREE=2;
public static final int SORTIE=3;
private int taille;
private boolean[][] grille;
private Cellules[][] grilleCellules;
private int[] tabCouleur;
public FenetreVideGrille(int taille){
super();
this.taille = taille;
this.grille = new boolean[this.taille][this.taille];
this.grilleCellules = new Cellules[this.taille][this.taille];
}
public void videGrille(){
this.fenetre.setSize(600, 600);
this.fenetre.setLocation(450, 200);
GridLayout gestionnaire = new GridLayout(this.taille,this.taille);
this.fenetre.setLayout(gestionnaire);
PanneauModification interfacePanel = new PanneauModification(this.grille, this.taille, this.grilleCellules, this.fenetre);
interfacePanel.SetUp();
/* =============================================================== */
/* =============================================================== */
for(int i=0; i<taille; i++){
for(int j=0; j<taille; j++){
Modifications modif = new Modifications(interfacePanel, this.grille, this.tabCouleur);
grille[i][j] = true;
Cellules cellules = new Cellules(i, j, COULOIR);
this.fenetre.add(cellules);
cellules.addMouseListener(modif);
this.tabCouleur = modif.getGateState();
}
}
this.fenetre.setVisible(true);
}
}