Auto
This commit is contained in:
parent
2b006f67f4
commit
bbdbc5b72d
BIN
Enter.class
BIN
Enter.class
Binary file not shown.
@ -49,6 +49,11 @@ public class Enter extends JPanel {
|
||||
});
|
||||
}
|
||||
|
||||
public int[][] getInitialGrid() {
|
||||
return initialGrid;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
BIN
Main.class
BIN
Main.class
Binary file not shown.
@ -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);
|
||||
|
BIN
Reset.class
Normal file
BIN
Reset.class
Normal file
Binary file not shown.
22
Reset.java
Normal file
22
Reset.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user