david session perdu
This commit is contained in:
55
DEV2.1/Flux_octet_Suite/Fond.java
Normal file
55
DEV2.1/Flux_octet_Suite/Fond.java
Normal file
@@ -0,0 +1,55 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Fond extends JPanel implements ActionListener{
|
||||
private Color coul_fond;
|
||||
|
||||
public Fond(Color couleur){
|
||||
super();
|
||||
// Création des boutons
|
||||
JButton cyanButton = new JButton("Cyan");
|
||||
JButton magentaButton = new JButton("Magenta");
|
||||
JButton yellowButton = new JButton("Jaune");
|
||||
|
||||
// Ajout des action listeners aux boutons
|
||||
cyanButton.addActionListener(this);
|
||||
magentaButton.addActionListener(this);
|
||||
yellowButton.addActionListener(this);
|
||||
|
||||
// Création du panneau pour contrôler la couleur de fond
|
||||
this.add(cyanButton);
|
||||
this.add(magentaButton);
|
||||
this.add(yellowButton);
|
||||
|
||||
this.setBackground(couleur);
|
||||
coul_fond = couleur;
|
||||
}
|
||||
|
||||
public Color Der_col(){
|
||||
return coul_fond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String command = e.getActionCommand();
|
||||
switch (command) {
|
||||
case "Cyan":
|
||||
this.setBackground(Color.CYAN);
|
||||
coul_fond = Color.CYAN;
|
||||
break;
|
||||
case "Magenta":
|
||||
this.setBackground(Color.MAGENTA);
|
||||
coul_fond = Color.MAGENTA;
|
||||
break;
|
||||
case "Jaune":
|
||||
this.setBackground(Color.YELLOW);
|
||||
coul_fond = Color.YELLOW;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
67
DEV2.1/Flux_octet_Suite/Memoire.java
Normal file
67
DEV2.1/Flux_octet_Suite/Memoire.java
Normal file
@@ -0,0 +1,67 @@
|
||||
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 {
|
||||
ObjectOutputStream dos = new ObjectOutputStream("position.bin");
|
||||
|
||||
Dimension dim = new Dimension(this.getWidth(),this.getHeight());
|
||||
Point poi = new Point(this.getX(),this.getY());
|
||||
Object dimension = (Object) dim;
|
||||
Object point = (Object) poi;
|
||||
Object coul = (Object)
|
||||
|
||||
dos.writeObject(xdimension);
|
||||
dos.writeObject(point);
|
||||
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 {
|
||||
ObjestInputStream dis = new ObjestInputStream("position.bin");
|
||||
Dimension dim = (Dimension) dis.readObject();
|
||||
Point poi = (Point) dis.readObject();
|
||||
Color col = (Color) dis.readObject();
|
||||
|
||||
this.setLocation(poi);
|
||||
this.setSize(dim);
|
||||
|
||||
Fond fond = new Fond();
|
||||
this.add(fond);
|
||||
|
||||
}catch(Exception e){
|
||||
System.out.println("Ouverture par defaut");
|
||||
this.setLocation(100, 100);
|
||||
this.setSize(500,500);
|
||||
Fond fond = new Fond(Color.WHITE);
|
||||
this.add(fond);
|
||||
}
|
||||
|
||||
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
|
||||
this.setVisible(true);
|
||||
this.addWindowListener(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
13
DEV2.1/Flux_octet_Suite/Test_memoire.java
Normal file
13
DEV2.1/Flux_octet_Suite/Test_memoire.java
Normal file
@@ -0,0 +1,13 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Test_memoire {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Memoire memoire = new Memoire();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user