SAE21_2022/FenetreVideGrille.java

63 lines
1.9 KiB
Java
Raw Normal View History

import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
public class FenetreVideGrille extends Fenetre{
private int[] tab_de_int;
2023-04-18 18:38:32 +02:00
private int Taille;
private int ValeurEntre;
private int ValeurSortie;
2023-04-18 18:38:32 +02:00
private JPanel[][] TabDePanel;
public FenetreVideGrille(int Taille){
super();
this.tab_de_int = new int[] {0, 0};
2023-04-18 18:38:32 +02:00
this.Taille = Taille;
this.TabDePanel = new JPanel[this.Taille][this.Taille];
}
public void CreerVide(){
this.fenetre.setSize(600, 600);
this.fenetre.setLocation(450, 200);
OptionsFVG un_Test = new OptionsFVG(this);
2023-04-18 18:38:32 +02:00
un_Test.SetUp();
GridLayout gestionnaire = new GridLayout(Taille,Taille);
this.fenetre.setLayout(gestionnaire);
2023-04-18 18:38:32 +02:00
for(int i=0; i<this.Taille; i++){
for(int j=0; j<this.Taille; j++){
JPanel ce_panel = new JPanel();
2023-04-18 18:38:32 +02:00
this.TabDePanel[j][i] = ce_panel;
Border border = BorderFactory.createLineBorder(Color.BLACK, 1);
ce_panel.setBorder(border);
ce_panel.setBackground(Color.WHITE);
this.fenetre.add(ce_panel);
ModificationsFVG testee = new ModificationsFVG(un_Test, this.tab_de_int);
ce_panel.addMouseListener(testee);
this.tab_de_int=testee.getValues();
}
}
this.fenetre.setVisible(true);
}
2023-04-18 18:38:32 +02:00
public int[] get_info(){
2023-04-18 18:38:32 +02:00
int[] infos_grille = new int[5];
infos_grille[0] = this.Taille;
infos_grille[1] = (this.ValeurEntre/this.Taille);
infos_grille[2] = (this.ValeurEntre%this.Taille);
infos_grille[3] = (this.ValeurSortie/this.Taille);
infos_grille[4] = (this.ValeurSortie%this.Taille);
return infos_grille;
}
public JPanel[][] getGrille(){
2023-04-18 18:38:32 +02:00
return this.TabDePanel;
}
}