Ajout des travaux effectuer
This commit is contained in:
BIN
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/Fond.class
Normal file
BIN
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/Fond.class
Normal file
Binary file not shown.
30
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/Fond.java
Normal file
30
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/Fond.java
Normal file
@@ -0,0 +1,30 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Fond extends JPanel implements ActionListener
|
||||
{
|
||||
public Fond(){
|
||||
super();
|
||||
JButton cyan = new JButton("Cyan");
|
||||
JButton magenta = new JButton("Magenta");
|
||||
JButton jaune = new JButton("Jaune");
|
||||
this.add(cyan);
|
||||
this.add(magenta);
|
||||
this.add(jaune);
|
||||
cyan.addActionListener(this);
|
||||
magenta.addActionListener(this);
|
||||
jaune.addActionListener(this);
|
||||
}
|
||||
public void actionPerformed(ActionEvent evenement){
|
||||
String test;
|
||||
test = evenement.getActionCommand();
|
||||
if(test.equals("Cyan")){
|
||||
this.setBackground(Color.CYAN);
|
||||
}if(test.equals("Magenta")){
|
||||
this.setBackground(Color.MAGENTA);
|
||||
}if(test.equals("Jaune")){
|
||||
this.setBackground(Color.YELLOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/Test.class
Normal file
BIN
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/Test.class
Normal file
Binary file not shown.
21
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/Test.java
Normal file
21
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/Test.java
Normal file
@@ -0,0 +1,21 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class Test{
|
||||
|
||||
public static void main(String[] args){
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.add(new Fond());
|
||||
fenetre.setVisible(true);
|
||||
try{
|
||||
FileInputStream file = new FileInputStream("/tmp/memoire/save.bin");
|
||||
BufferedInputStream buff = new BufferedInputStream(file);
|
||||
}catch(IOException e){
|
||||
fenetre.setSize(300, 300);
|
||||
fenetre.setLocation(100, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
36
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/memoire.java
Normal file
36
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/memoire.java
Normal file
@@ -0,0 +1,36 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class memoire{
|
||||
public void windowOpened(WindowEvent event){
|
||||
Window window = event.getWindow();
|
||||
Point defaultLocation = new Point(0, 0);
|
||||
Dimension defaultDimension = Dimension(400, 400);
|
||||
try(ObjectInputStream input = new ObjectInputStream(new FileInputStream("/tmp/memoire/save.bin"))){
|
||||
Object location = input.readObject();
|
||||
Object size = input.readObject();
|
||||
if(size instanceof Point){
|
||||
defaultLocation = (Point)location;
|
||||
}
|
||||
if(size instanceof Dimension){
|
||||
defaultDimension = (Dimension)size;
|
||||
}
|
||||
}catch(IOException | ClassNotFoundException e){
|
||||
}
|
||||
window.setLocation(defaultLocation);
|
||||
window.setSize(defaultDimension);
|
||||
}
|
||||
public void windowClosing(WindowEvent event){
|
||||
Window window = event.getWindow();
|
||||
try(ObjectOutputStream input = new ObjectOutputStream(new FileOutputStream("/tmp/memoire/save.bin"))){
|
||||
input.writeObject(window.getLocation());
|
||||
input.writeObject(window.getSize());
|
||||
}catch(IOException | ClassNotFoundException e){
|
||||
System.out.println(e.getMessage);
|
||||
}
|
||||
}
|
||||
public memoire(){
|
||||
super();
|
||||
}
|
||||
}
|
||||
36
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/memory.java
Normal file
36
23DEV1.1/TPS2/TP01/FluxDOctet/Mémoire/memory.java
Normal file
@@ -0,0 +1,36 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class memoire extends implement{
|
||||
public void windowOpened(WindowEvent event){
|
||||
Window window = event.getWindow();
|
||||
Point defaultLocation = new Point(0, 0);
|
||||
Dimension defaultDimension = Dimension(400, 400);
|
||||
try(ObjectInputStream input = new ObjectInputStream(new FileInputStream("/tmp/memoire/save.bin"))){
|
||||
Object location = input.readObject();
|
||||
Object size = input.readObject();
|
||||
if(size instanceof Point){
|
||||
defaultLocation = (Point)location;
|
||||
}
|
||||
if(size instanceof Dimension){
|
||||
defaultDimension = (Dimension)size;
|
||||
}
|
||||
}catch(IOException | ClassNotFoundException e){
|
||||
}
|
||||
window.setLocation(defaultLocation);
|
||||
window.setSize(defaultDimension);
|
||||
}
|
||||
public void windowClosing(WindowEvent event){
|
||||
Window window = event.getWindow();
|
||||
try(ObjectOutputStream input = new ObjectOutputStream(new FileOutputStream("/tmp/memoire/save.bin"))){
|
||||
input.writeObject(window.getLocation());
|
||||
input.writeObject(window.getSize());
|
||||
}catch(IOException | ClassNotFoundException e){
|
||||
System.out.println(e.getMessage);
|
||||
}
|
||||
}
|
||||
public memoire(){
|
||||
super();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user