9 Mai
This commit is contained in:
parent
93c00d1ed0
commit
392e9a21f8
BIN
DEV2.1/TP9:FluxOctets/Fond2.class
Normal file
BIN
DEV2.1/TP9:FluxOctets/Fond2.class
Normal file
Binary file not shown.
36
DEV2.1/TP9:FluxOctets/Fond2.java
Normal file
36
DEV2.1/TP9:FluxOctets/Fond2.java
Normal file
@ -0,0 +1,36 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Fond2 extends JPanel implements ActionListener{
|
||||
|
||||
public Fond2() {
|
||||
super();
|
||||
JButton magenta = new JButton("magenta");
|
||||
JButton cyan = new JButton("cyan");
|
||||
JButton jaune = new JButton("jaune");
|
||||
this.add(magenta);
|
||||
this.add(cyan);
|
||||
this.add(jaune);
|
||||
magenta.addActionListener(this);
|
||||
cyan.addActionListener(this);
|
||||
jaune.addActionListener(this);
|
||||
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evenement){
|
||||
String commande = new String();
|
||||
commande="cyan";
|
||||
if(true==commande.equals(evenement.getActionCommand())){
|
||||
this.setBackground(Color.CYAN);
|
||||
}
|
||||
commande="magenta";
|
||||
if(true==commande.equals(evenement.getActionCommand())){
|
||||
this.setBackground(Color.MAGENTA);
|
||||
}
|
||||
commande="jaune";
|
||||
if(true==commande.equals(evenement.getActionCommand())){
|
||||
this.setBackground(Color.YELLOW);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
@ -13,6 +13,7 @@ public class Imag extends JComponent{
|
||||
|
||||
private Image readFromFile(int width, int height, String path) throws IOException {
|
||||
FileInputStream input = new FileInputStream(path);
|
||||
BufferedInputStream input2 = new BufferedInputStream(input);
|
||||
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
|
||||
for (int i = 0; i < height; i++){
|
||||
for (int j = 0; j < width; j++){
|
||||
@ -36,6 +37,6 @@ public class Imag extends JComponent{
|
||||
pinceau2.setColor(this.getBackground());
|
||||
pinceau2.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
pinceau2.drawImage(this.image, 768, 1024, this);
|
||||
pinceau2.drawImage(this.image, 0, 0, this);
|
||||
}
|
||||
}
|
Binary file not shown.
@ -7,6 +7,7 @@ public class MainImage{
|
||||
public static void main(String[] args) {
|
||||
try{
|
||||
FileInputStream file = new FileInputStream("image.bin");
|
||||
BufferedInputStream file2 = new BufferedInputStream(file);
|
||||
try {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(1024, 768);
|
||||
@ -15,7 +16,7 @@ public class MainImage{
|
||||
fenetre.add(new Imag(1024, 768, "image.bin"));
|
||||
fenetre.setVisible(true);
|
||||
fenetre.pack();
|
||||
file.close();
|
||||
file2.close();
|
||||
} catch(IOException e){}
|
||||
}catch(FileNotFoundException e){}
|
||||
}
|
||||
|
BIN
DEV2.1/TP9:FluxOctets/Mainfond2.class
Normal file
BIN
DEV2.1/TP9:FluxOctets/Mainfond2.class
Normal file
Binary file not shown.
33
DEV2.1/TP9:FluxOctets/Mainfond2.java
Normal file
33
DEV2.1/TP9:FluxOctets/Mainfond2.java
Normal file
@ -0,0 +1,33 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Mainfond2{
|
||||
|
||||
public static void main(String[] args) {
|
||||
try{
|
||||
DataInputStream file = new DataInputStream(new FileInputStream ("taille.bin"));
|
||||
BufferedInputStream file2 = new BufferedInputStream(file);
|
||||
try {
|
||||
JFrame fenetre = new JFrame();
|
||||
Fond2 pan = new Fond2();
|
||||
int x = file.readInt();
|
||||
int y = file.readInt();
|
||||
fenetre.setSize(x, y);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.setContentPane(pan);
|
||||
fenetre.setVisible(true);
|
||||
file2.close();
|
||||
} catch(IOException e){}
|
||||
}catch(FileNotFoundException e){
|
||||
JFrame fenetre = new JFrame();
|
||||
Fond2 pan = new Fond2();
|
||||
fenetre.setSize(500, 500);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.setContentPane(pan);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
0
DEV2.1/TP9:FluxOctets/taille.bin
Normal file
0
DEV2.1/TP9:FluxOctets/taille.bin
Normal file
Loading…
Reference in New Issue
Block a user