save ok!
This commit is contained in:
parent
9c0bc0faa8
commit
c23cf8c655
@ -1,4 +0,0 @@
|
||||
|
||||
public interface ActionListener {
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ public class Banniere extends JPanel {
|
||||
|
||||
// Bouton pour sauver et quitter
|
||||
this.save = new JButton("Sauver et quitter");
|
||||
//save.addActionListener(new SaveListener(grille));
|
||||
save.addActionListener(new SaveListener(grille, fenetre));
|
||||
this.add(this.save, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class FrameJeu extends JFrame{
|
||||
// Récupération de la bannière
|
||||
Banniere banniere = grille.getBanniere();
|
||||
|
||||
|
||||
this.addWindowListener(new SaveAndCloseListener(grille));
|
||||
|
||||
// Mise en place de la bannière
|
||||
miseEnPage.fill = GridBagConstraints.BOTH;
|
||||
|
2
Save.txt
Normal file
2
Save.txt
Normal file
@ -0,0 +1,2 @@
|
||||
30x9
|
||||
100000000001000000010000000000000000000100010000110000000000010000100000000000000000000000001000000010000000001100100000011011100100100000001010000000010000000100000000000000010101100100011000100101000010001011100000000000000001000100000000001100101000100000001000110000
|
40
SaveAndCloseListener.java
Normal file
40
SaveAndCloseListener.java
Normal file
@ -0,0 +1,40 @@
|
||||
import java.awt.event.*;
|
||||
public class SaveAndCloseListener implements WindowListener{
|
||||
private Grille grille;
|
||||
public SaveAndCloseListener(Grille grille){
|
||||
this.grille=grille;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
SaveManager saveManager = new SaveManager();
|
||||
saveManager.save(this.grille, "Save.txt");
|
||||
SaveManager.SaveData donnees = saveManager.load("Save.txt");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowIconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowActivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
}
|
17
SaveListener.java
Normal file
17
SaveListener.java
Normal file
@ -0,0 +1,17 @@
|
||||
import java.awt.event.*;
|
||||
public class SaveListener implements ActionListener {
|
||||
private Grille grille;
|
||||
private FrameJeu fenetre;
|
||||
public SaveListener(Grille grille, FrameJeu fenetre){
|
||||
this.grille=grille;
|
||||
this.fenetre=fenetre;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event){
|
||||
SaveManager saveManager = new SaveManager();
|
||||
saveManager.save(this.grille, "Save.txt");
|
||||
SaveManager.SaveData donnees = saveManager.load("Save.txt");
|
||||
this.fenetre.dispose();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user