SAE21_2023/Reset.java

23 lines
625 B
Java
Raw Normal View History

2024-04-03 12:08:54 +02:00
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();
}
}