import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; import java.io.File; import java.io.PrintWriter; import java.io.FileWriter; import java.io.IOException; import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; public class MainCreation { public static void main(String[] args) { //Création de la fenetre de selection + choix du dossier JFrame selF = new JFrame("Choix de résolution du Sudoku"); selF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); selF.setSize(400, 200); selF.setLayout(new BorderLayout()); selF.setLocationRelativeTo(null); JLabel sel = new JLabel("Quelle grilles souhaitez vous ?"); //Création des boutons sel.setHorizontalAlignment(JLabel.CENTER); JButton grilleVide = new JButton("Grille vide"); JButton grilleExiste = new JButton("Grille Existante"); JPanel boutonsSelect = new JPanel(); boutonsSelect.setLayout(new FlowLayout()); boutonsSelect.add(grilleVide); boutonsSelect.add(grilleExiste); selF.add(sel, BorderLayout.NORTH); selF.add(boutonsSelect, BorderLayout.CENTER); selF.setVisible(true); //Action des bouton grilleVide.addActionListener(new GrilleVideActionListener(selF)); grilleExiste.addActionListener(new GrilleExisteActionListener(selF)); /*grilleVide.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selF.dispose(); Grilles.grilleVide(grille); FenetreModif.fenetreModification(grille); } });*/ /* grilleExiste.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selF.dispose(); JFileChooser fileChooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("File grille","gri"); fileChooser.setFileFilter(filter); File workingDirectory = new File(System.getProperty("user.dir")); fileChooser.setCurrentDirectory(workingDirectory); JPanel panneau = new JPanel(); int valeur_de_retour = fileChooser.showOpenDialog(panneau); if(valeur_de_retour == JFileChooser.APPROVE_OPTION) { Lecteur.lecture(fileChooser.getSelectedFile(), grille); FenetreModif.fenetreModification(grille); } } });*/ } }