Intégration de la fonctionnalité au menu

This commit is contained in:
Lyanis SOUIDI 2023-04-28 03:16:05 +02:00
parent 4446af333f
commit 19349d89ae
Signed by: Lyanis SOUIDI
GPG Key ID: 251ADD56CFE6A854

View File

@ -95,7 +95,7 @@ public class HomeView extends JPanel {
return choisirGrille; return choisirGrille;
} }
private static JButton importerGrille(JFrame window) { private static JButton importerGrille(Window window) {
JPanel panel = new JPanel(); JPanel panel = new JPanel();
JButton importerGrille = new JButton("Importer une grille"); JButton importerGrille = new JButton("Importer une grille");
importerGrille.setPreferredSize(new Dimension(250, 50)); importerGrille.setPreferredSize(new Dimension(250, 50));
@ -108,7 +108,14 @@ public class HomeView extends JPanel {
int choix = fileChooser.showOpenDialog(panel); int choix = fileChooser.showOpenDialog(panel);
if (choix == JFileChooser.APPROVE_OPTION) { if (choix == JFileChooser.APPROVE_OPTION) {
File fichier = fileChooser.getSelectedFile(); File fichier = fileChooser.getSelectedFile();
// TODO: charger la grille depuis le fichier try {
GridView gridView = new GridView(window);
new GridController(FileManager.importGrid(fichier), gridView);
window.setContentPane(gridView);
window.validate();
} catch (Exception ex) {
JOptionPane.showMessageDialog(panel, ex.getMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);
}
} }
}); });