diff --git a/DEV2.1/TP9:FluxOctets/Fond2.class b/DEV2.1/TP9:FluxOctets/Fond2.class new file mode 100644 index 0000000..bdb5176 Binary files /dev/null and b/DEV2.1/TP9:FluxOctets/Fond2.class differ diff --git a/DEV2.1/TP9:FluxOctets/Fond2.java b/DEV2.1/TP9:FluxOctets/Fond2.java new file mode 100644 index 0000000..5ff587f --- /dev/null +++ b/DEV2.1/TP9:FluxOctets/Fond2.java @@ -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); + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP9:FluxOctets/Imag.class b/DEV2.1/TP9:FluxOctets/Imag.class index 50332e6..bd9795d 100644 Binary files a/DEV2.1/TP9:FluxOctets/Imag.class and b/DEV2.1/TP9:FluxOctets/Imag.class differ diff --git a/DEV2.1/TP9:FluxOctets/Imag.java b/DEV2.1/TP9:FluxOctets/Imag.java index 0b104a0..598d56a 100644 --- a/DEV2.1/TP9:FluxOctets/Imag.java +++ b/DEV2.1/TP9:FluxOctets/Imag.java @@ -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); } } \ No newline at end of file diff --git a/DEV2.1/TP9:FluxOctets/MainImage.class b/DEV2.1/TP9:FluxOctets/MainImage.class index 4bdecc1..1313ff5 100644 Binary files a/DEV2.1/TP9:FluxOctets/MainImage.class and b/DEV2.1/TP9:FluxOctets/MainImage.class differ diff --git a/DEV2.1/TP9:FluxOctets/MainImage.java b/DEV2.1/TP9:FluxOctets/MainImage.java index a9e5dad..6eea657 100644 --- a/DEV2.1/TP9:FluxOctets/MainImage.java +++ b/DEV2.1/TP9:FluxOctets/MainImage.java @@ -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){} } diff --git a/DEV2.1/TP9:FluxOctets/Mainfond2.class b/DEV2.1/TP9:FluxOctets/Mainfond2.class new file mode 100644 index 0000000..8549832 Binary files /dev/null and b/DEV2.1/TP9:FluxOctets/Mainfond2.class differ diff --git a/DEV2.1/TP9:FluxOctets/Mainfond2.java b/DEV2.1/TP9:FluxOctets/Mainfond2.java new file mode 100644 index 0000000..8606545 --- /dev/null +++ b/DEV2.1/TP9:FluxOctets/Mainfond2.java @@ -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); + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP9:FluxOctets/taille.bin b/DEV2.1/TP9:FluxOctets/taille.bin new file mode 100644 index 0000000..e69de29