diff --git a/EssaiChoixFichier.class b/EssaiChoixFichier.class new file mode 100644 index 0000000..3ef8064 Binary files /dev/null and b/EssaiChoixFichier.class differ diff --git a/EssaiChoixFichier.java b/EssaiChoixFichier.java new file mode 100644 index 0000000..09e1b5f --- /dev/null +++ b/EssaiChoixFichier.java @@ -0,0 +1,15 @@ +import java.io.File; +import java.io.PrintWriter; +import java.io.FileWriter; +import java.io.IOException; +import javax.swing.JFileChooser; + +class EssaiChoixFichier { + public static void main(String[] arg) throws IOException { + JFileChooser dialogue = new JFileChooser(new File(".")); + + if (dialogue.showOpenDialog(null)==JFileChooser.APPROVE_OPTION) { + dialogue.getSelectedFile(); + } + } +} \ No newline at end of file diff --git a/MainCreation$1.class b/MainCreation$1.class new file mode 100644 index 0000000..ddccb18 Binary files /dev/null and b/MainCreation$1.class differ diff --git a/MainCreation$2.class b/MainCreation$2.class new file mode 100644 index 0000000..c7899dd Binary files /dev/null and b/MainCreation$2.class differ diff --git a/MainCreation$3.class b/MainCreation$3.class new file mode 100644 index 0000000..4b6a0aa Binary files /dev/null and b/MainCreation$3.class differ diff --git a/MainCreation.class b/MainCreation.class new file mode 100644 index 0000000..681e32f Binary files /dev/null and b/MainCreation.class differ diff --git a/MainCreation.java b/MainCreation.java new file mode 100644 index 0000000..b775c66 --- /dev/null +++ b/MainCreation.java @@ -0,0 +1,89 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.io.File; +import java.io.PrintWriter; +import java.io.FileWriter; +import java.io.IOException; +import javax.swing.JFileChooser; + +public class MainCreation { + public static void main(String[] args) { + //Création de la fenetre de selection + 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 ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + selF.dispose(); + int[][] grille = grilleVide(); + fenetreModification(grille, false); + } + }); + grilleExiste.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + selF.dispose(); + int[][] grille = SudokuGenerator.readGridFromFile(); + fenetreModification(grille, false); + } + }); + } + public static int[][] grilleVide() { + int[][] g = { + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0} + }; + return g; + } + private static void fenetreModification(int[][] grille, boolean modeAutomatique) { + JFrame frame = new JFrame("Sudoku"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + SaisieGrille saisieGrille = new SaisieGrille(grille); // Utilisation de la classe SaisieGrille pour permettre la saisie des valeurs + JButton register = new JButton("Enregistrer"); + register.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e){ + JFileChooser dialogue = new JFileChooser(new File(".")); + if (dialogue.showOpenDialog(null)==JFileChooser.APPROVE_OPTION) { + dialogue.getSelectedFile(); + } + } + }); + + frame.add(register, BorderLayout.SOUTH); // Ajouter le bouton "Enregistrer" + + frame.add(saisieGrille, BorderLayout.CENTER); // Ajouter la grille à la fenêtre + + frame.pack(); + frame.setLocationRelativeTo(null); // Centrer la fenêtre sur l'écran + frame.setVisible(true); + + System.out.println("La fenêtre de création a été affichée."); + } +} diff --git a/SaisieGrille$1.class b/SaisieGrille$1.class index 5ad4860..73d31e9 100644 Binary files a/SaisieGrille$1.class and b/SaisieGrille$1.class differ diff --git a/SaisieGrille.class b/SaisieGrille.class index 3a5691e..adb54b4 100644 Binary files a/SaisieGrille.class and b/SaisieGrille.class differ diff --git a/SudokuGenerator.class b/SudokuGenerator.class new file mode 100644 index 0000000..0511a21 Binary files /dev/null and b/SudokuGenerator.class differ