flut d'octet
This commit is contained in:
70
DEV2.1/Flux_octet/Memoire/Memoire.java
Normal file
70
DEV2.1/Flux_octet/Memoire/Memoire.java
Normal file
@@ -0,0 +1,70 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Memoire extends JFrame implements WindowListener{
|
||||
public void windowClosed(WindowEvent evenement){}
|
||||
public void windowActivated(WindowEvent evenement){}
|
||||
public void windowClosing(WindowEvent evenement){
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream("position.bin");
|
||||
DataOutputStream dos = new DataOutputStream(fos);
|
||||
|
||||
int w = this.getWidth();
|
||||
int h = this.getHeight();
|
||||
int x = this.getX();
|
||||
int y = this.getY();
|
||||
|
||||
dos.writeInt(x);
|
||||
dos.writeInt(y);
|
||||
dos.writeInt(h);
|
||||
dos.writeInt(w);
|
||||
System.out.println("info stockee");
|
||||
|
||||
|
||||
this.dispose();
|
||||
}catch(Exception e){
|
||||
System.out.println("erreur stockage");
|
||||
}
|
||||
|
||||
}
|
||||
public void windowDeactivated(WindowEvent evenement){}
|
||||
public void windowDeiconified(WindowEvent evenement){}
|
||||
public void windowIconified(WindowEvent evenement){}
|
||||
public void windowOpened(WindowEvent evenement){}
|
||||
|
||||
|
||||
public Memoire(){
|
||||
super();
|
||||
|
||||
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream("position.bin");
|
||||
DataInputStream dis = new DataInputStream(fis);
|
||||
int x = dis.readInt();
|
||||
int y = dis.readInt();
|
||||
int h = dis.readInt();
|
||||
int w = dis.readInt();
|
||||
|
||||
this.setLocation(x,y);
|
||||
this.setSize(w,h);
|
||||
|
||||
}catch(Exception e){
|
||||
System.out.println("Ouverture par defaut");
|
||||
this.setLocation(100, 100);
|
||||
this.setSize(500,500);
|
||||
}
|
||||
|
||||
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
|
||||
Fond fond = new Fond();
|
||||
this.add(fond);
|
||||
|
||||
this.setVisible(true);
|
||||
this.addWindowListener(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user