diff --git a/Enter.class b/Enter.class index ac23308..a429358 100644 Binary files a/Enter.class and b/Enter.class differ diff --git a/Enter.java b/Enter.java index 401795d..d93f60a 100644 --- a/Enter.java +++ b/Enter.java @@ -49,8 +49,13 @@ public class Enter extends JPanel { }); } + public int[][] getInitialGrid() { + return initialGrid; + } + + @Override -protected void paintComponent(Graphics g) { + protected void paintComponent(Graphics g) { super.paintComponent(g); // Dessiner les contours de la grille (en gras) diff --git a/Main.class b/Main.class index 2a14126..90fd4f0 100644 Binary files a/Main.class and b/Main.class differ diff --git a/Main.java b/Main.java index faffd2e..b4b1d66 100644 --- a/Main.java +++ b/Main.java @@ -24,6 +24,9 @@ public class Main { frame.add(enterPanel, BorderLayout.CENTER); frame.add(buttonPanel, BorderLayout.SOUTH); + // Ajout de l'écouteur d'événements au bouton "Reset" + resetButton.addActionListener(new Reset(grid, enterPanel)); + frame.pack(); frame.setLocationRelativeTo(null); // Centrer la fenêtre sur l'écran frame.setVisible(true); diff --git a/Reset.class b/Reset.class new file mode 100644 index 0000000..bba0690 Binary files /dev/null and b/Reset.class differ diff --git a/Reset.java b/Reset.java new file mode 100644 index 0000000..7030942 --- /dev/null +++ b/Reset.java @@ -0,0 +1,22 @@ +import javax.swing.*; +import java.awt.event.*; + +public class Reset implements ActionListener { + private int[][] grid; + private Enter enterPanel; + + public Reset(int[][] grid, Enter enterPanel) { + this.grid = grid; + this.enterPanel = enterPanel; + } + + @Override + public void actionPerformed(ActionEvent e) { + // Réinitialiser la grille en copiant la grille initiale + for (int i = 0; i < grid.length; i++) { + System.arraycopy(enterPanel.getInitialGrid()[i], 0, grid[i], 0, grid[i].length); + } + // Redessiner le panneau + enterPanel.repaint(); + } +}