Presque Fini

This commit is contained in:
raban 2024-05-02 17:36:25 +02:00
parent 0d812b9b4c
commit 5ad331149b
32 changed files with 121 additions and 44 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
FenetreModif$1.class Normal file

Binary file not shown.

BIN
FenetreModif.class Normal file

Binary file not shown.

46
FenetreModif.java Normal file
View File

@ -0,0 +1,46 @@
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 FenetreModif{
public static void fenetreModification(int[][] grille) {
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 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) {
Register.sauvegarde(fileChooser.getSelectedFile(), grille);
}
}
});
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.");
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,38 @@
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 GrilleExisteActionListener implements ActionListener{
private JFrame choixFrame;
public GrilleExisteActionListener(JFrame choixFrame) {
this.choixFrame = choixFrame;
}
@Override
public void actionPerformed(ActionEvent e) {
choixFrame.dispose();
int [][] grille = new int [9][9];
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);
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,28 @@
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 GrilleVideActionListener implements ActionListener{
private JFrame choixFrame;
public GrilleVideActionListener(JFrame choixFrame) {
this.choixFrame = choixFrame;
}
@Override
public void actionPerformed(ActionEvent e) {
int [][] grille = new int [9][9];
choixFrame.dispose();
Grilles.grilleVide(grille);
FenetreModif.fenetreModification(grille);
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -41,6 +41,5 @@ public class Lecteur{
}
valeur_actuelle=0;
}
System.out.print("Fichier enregistrer");
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -11,7 +11,6 @@ import javax.swing.filechooser.FileNameExtensionFilter;
public class MainCreation {
public static void main(String[] args) {
int [][] grille = new int [9][9];
//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);
@ -33,15 +32,16 @@ public class MainCreation {
selF.add(boutonsSelect, BorderLayout.CENTER);
selF.setVisible(true);
//Action des bouton
grilleVide.addActionListener(new ActionListener() {
@Override
grilleVide.addActionListener(new GrilleVideActionListener(selF));
grilleExiste.addActionListener(new GrilleExisteActionListener(selF));
/*grilleVide.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
selF.dispose();
Grilles.grilleVide(grille);
fenetreModification(grille);
FenetreModif.fenetreModification(grille);
}
});
grilleExiste.addActionListener(new ActionListener() {
});*/
/* grilleExiste.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selF.dispose();
@ -56,43 +56,9 @@ public class MainCreation {
int valeur_de_retour = fileChooser.showOpenDialog(panneau);
if(valeur_de_retour == JFileChooser.APPROVE_OPTION) {
Lecteur.lecture(fileChooser.getSelectedFile(), grille);
fenetreModification(grille);
FenetreModif.fenetreModification(grille);
}
}
});
}
private static void fenetreModification(int[][] grille) {
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 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) {
Register.sauvegarde(fileChooser.getSelectedFile(), grille);
}
}
});
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.");
});*/
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.