SAE21_2023/MainCreation.java

65 lines
2.6 KiB
Java
Raw Normal View History

2024-04-30 13:51:32 +02:00
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
2024-05-01 19:03:45 +02:00
import java.io.*;
2024-04-30 13:51:32 +02:00
import java.io.File;
import java.io.PrintWriter;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JFileChooser;
2024-05-01 19:03:45 +02:00
import javax.swing.filechooser.FileNameExtensionFilter;
2024-04-30 13:51:32 +02:00
public class MainCreation {
public static void main(String[] args) {
2024-05-01 19:03:45 +02:00
//Création de la fenetre de selection + choix du dossier
2024-04-30 13:51:32 +02:00
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
2024-05-02 17:36:25 +02:00
grilleVide.addActionListener(new GrilleVideActionListener(selF));
grilleExiste.addActionListener(new GrilleExisteActionListener(selF));
/*grilleVide.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
2024-04-30 13:51:32 +02:00
selF.dispose();
2024-05-01 19:03:45 +02:00
Grilles.grilleVide(grille);
2024-05-02 17:36:25 +02:00
FenetreModif.fenetreModification(grille);
2024-04-30 13:51:32 +02:00
}
2024-05-02 17:36:25 +02:00
});*/
/* grilleExiste.addActionListener(new ActionListener() {
2024-04-30 13:51:32 +02:00
@Override
public void actionPerformed(ActionEvent e) {
selF.dispose();
2024-05-02 12:12:32 +02:00
JFileChooser fileChooser = new JFileChooser();
2024-05-01 19:03:45 +02:00
FileNameExtensionFilter filter = new FileNameExtensionFilter("File grille","gri");
2024-05-02 12:12:32 +02:00
fileChooser.setFileFilter(filter);
2024-05-01 19:03:45 +02:00
File workingDirectory = new File(System.getProperty("user.dir"));
2024-05-02 12:12:32 +02:00
fileChooser.setCurrentDirectory(workingDirectory);
2024-05-01 19:03:45 +02:00
JPanel panneau = new JPanel();
2024-05-02 12:12:32 +02:00
int valeur_de_retour = fileChooser.showOpenDialog(panneau);
2024-05-01 19:03:45 +02:00
if(valeur_de_retour == JFileChooser.APPROVE_OPTION) {
2024-05-02 12:12:32 +02:00
Lecteur.lecture(fileChooser.getSelectedFile(), grille);
2024-05-02 17:36:25 +02:00
FenetreModif.fenetreModification(grille);
2024-05-01 19:03:45 +02:00
}
2024-04-30 13:51:32 +02:00
}
2024-05-02 17:36:25 +02:00
});*/
2024-04-30 13:51:32 +02:00
}
}