SAE21_2022/importer.java

47 lines
1.4 KiB
Java

import java.awt.event.*;
import javax.swing.JFrame;
public class importer implements ActionListener {
String cette_option;
String cet_event;
String ce_chemin;
JFrame cette_frame;
Lecture cette_lecture;
FenetreImpGrille cette_fenetre;
int valeur0, valeur1, valeur2, valeur3, valeur4;
public importer(JFrame une_frame){
this.cette_option="Importer Grille";
this.cette_frame = une_frame;
}
public void actionPerformed(ActionEvent e){
this.cet_event=e.getActionCommand();
if(cet_event.equals(this.cette_option)){
System.out.println("Importation de la grille");
/*cherche le chemin du fichier */
FileImport un_test = new FileImport();
this.ce_chemin = un_test.Parcours();
/*lecture du fichier */
this.cette_lecture = new Lecture(this.ce_chemin);
this.valeur0=this.cette_lecture.GetHeader(0);
this.valeur1=this.cette_lecture.GetHeader(1);
this.valeur2=this.cette_lecture.GetHeader(2);
this.valeur3=this.cette_lecture.GetHeader(3);
this.valeur4=this.cette_lecture.GetHeader(4);
/*Fermeture de la première fenètre */
cette_frame.dispose();
/* Ouverture de la nouvelle */
this.cette_fenetre = new FenetreImpGrille();
cette_fenetre.ImporterGrille(this.valeur0, this.valeur1, this.valeur2, this.valeur3, this.valeur4, this.cette_lecture.GetOffset());
}
}
}