register
This commit is contained in:
parent
f1298238a9
commit
42c4ee8f89
BIN
EssaiChoixFichier.class
Normal file
BIN
EssaiChoixFichier.class
Normal file
Binary file not shown.
15
EssaiChoixFichier.java
Normal file
15
EssaiChoixFichier.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
BIN
MainCreation$1.class
Normal file
BIN
MainCreation$1.class
Normal file
Binary file not shown.
BIN
MainCreation$2.class
Normal file
BIN
MainCreation$2.class
Normal file
Binary file not shown.
BIN
MainCreation$3.class
Normal file
BIN
MainCreation$3.class
Normal file
Binary file not shown.
BIN
MainCreation.class
Normal file
BIN
MainCreation.class
Normal file
Binary file not shown.
89
MainCreation.java
Normal file
89
MainCreation.java
Normal file
@ -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.");
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
BIN
SudokuGenerator.class
Normal file
BIN
SudokuGenerator.class
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user