Controle machine
This commit is contained in:
BIN
DEV2.1/CM1/01_Filtre/Filtre.class
Normal file
BIN
DEV2.1/CM1/01_Filtre/Filtre.class
Normal file
Binary file not shown.
13
DEV2.1/CM1/01_Filtre/Filtre.java
Normal file
13
DEV2.1/CM1/01_Filtre/Filtre.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class Filtre {
|
||||||
|
public static String minusculesDansChaine(String chaine) {
|
||||||
|
String chaineFinale = "";
|
||||||
|
for (int i = 0; i != chaine.length(); i++) {
|
||||||
|
if(Character.isLowerCase(chaine.charAt(i))) {
|
||||||
|
chaineFinale += chaine.charAt(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return chaineFinale;
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/CM1/01_Filtre/Main.class
Normal file
BIN
DEV2.1/CM1/01_Filtre/Main.class
Normal file
Binary file not shown.
14
DEV2.1/CM1/01_Filtre/Main.java
Normal file
14
DEV2.1/CM1/01_Filtre/Main.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
// Tests de la méthode
|
||||||
|
/* String texte = "CeCi eSt uN TesT";
|
||||||
|
String texte2 = "mMiAnJuUsScCuUlLeEsS ";
|
||||||
|
System.out.println(Filtre.minusculesDansChaine(texte));
|
||||||
|
System.out.println(Filtre.minusculesDansChaine(texte2)); */
|
||||||
|
|
||||||
|
for (String chaine : args) {
|
||||||
|
System.out.println(Filtre.minusculesDansChaine(chaine));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/CM1/02_Exquis/Exquis.class
Normal file
BIN
DEV2.1/CM1/02_Exquis/Exquis.class
Normal file
Binary file not shown.
16
DEV2.1/CM1/02_Exquis/Exquis.java
Normal file
16
DEV2.1/CM1/02_Exquis/Exquis.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class Exquis {
|
||||||
|
|
||||||
|
private String[] chaines;
|
||||||
|
|
||||||
|
public Exquis(String[] chaines) {
|
||||||
|
this.chaines = chaines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
Random aleatoire = new Random();
|
||||||
|
return this.chaines[Math.abs(aleatoire.nextInt()) % this.chaines.length];
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/CM1/02_Exquis/Main.class
Normal file
BIN
DEV2.1/CM1/02_Exquis/Main.class
Normal file
Binary file not shown.
35
DEV2.1/CM1/02_Exquis/Main.java
Normal file
35
DEV2.1/CM1/02_Exquis/Main.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String[] sujets = {
|
||||||
|
"Luc",
|
||||||
|
"Denis",
|
||||||
|
"Régine",
|
||||||
|
"Selma",
|
||||||
|
"Frédéric"
|
||||||
|
};
|
||||||
|
|
||||||
|
String[] verbes = {
|
||||||
|
"aime",
|
||||||
|
"déteste",
|
||||||
|
"tue",
|
||||||
|
"mange",
|
||||||
|
"épouse"
|
||||||
|
};
|
||||||
|
|
||||||
|
String[] complements = {
|
||||||
|
"Windows",
|
||||||
|
"les pommes",
|
||||||
|
"Elizabeth II",
|
||||||
|
"les batyscaphes" // Je sais même pas si c'est un nom commun en vrai
|
||||||
|
};
|
||||||
|
|
||||||
|
Exquis sujet = new Exquis(sujets);
|
||||||
|
Exquis verbe = new Exquis(verbes);
|
||||||
|
Exquis complement = new Exquis(complements);
|
||||||
|
|
||||||
|
for (int i = 0; i != 5; i++) {
|
||||||
|
System.out.println(sujet + " " + verbe + " " + complement);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/CM1/03_Compteur/6.png
Normal file
BIN
DEV2.1/CM1/03_Compteur/6.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
DEV2.1/CM1/03_Compteur/Fenetre.class
Normal file
BIN
DEV2.1/CM1/03_Compteur/Fenetre.class
Normal file
Binary file not shown.
31
DEV2.1/CM1/03_Compteur/Fenetre.java
Normal file
31
DEV2.1/CM1/03_Compteur/Fenetre.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class Fenetre extends JFrame {
|
||||||
|
|
||||||
|
public Fenetre() {
|
||||||
|
this.setSize(250, 300);
|
||||||
|
this.setLocation(100, 100);
|
||||||
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
this.setLayout(new BorderLayout());
|
||||||
|
|
||||||
|
JPanel panneauHaut = new JPanel();
|
||||||
|
JPanel panneauBas = new JPanel();
|
||||||
|
JPanel panneauMilieu = new JPanel();
|
||||||
|
|
||||||
|
JButton boutonHaut = new JButton("\u25B2");
|
||||||
|
JButton boutonBas = new JButton("\u25BC");
|
||||||
|
Six imageSix = new Six();
|
||||||
|
|
||||||
|
boutonHaut.setHorizontalAlignment(JButton.CENTER);
|
||||||
|
boutonBas.setHorizontalAlignment(JButton.CENTER);
|
||||||
|
|
||||||
|
panneauHaut.add(boutonHaut);
|
||||||
|
panneauBas.add(boutonBas);
|
||||||
|
panneauMilieu.add(imageSix);
|
||||||
|
|
||||||
|
this.add(panneauHaut, BorderLayout.NORTH);
|
||||||
|
this.add(panneauBas, BorderLayout.SOUTH);
|
||||||
|
this.add(imageSix, BorderLayout.CENTER);
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/CM1/03_Compteur/Main.class
Normal file
BIN
DEV2.1/CM1/03_Compteur/Main.class
Normal file
Binary file not shown.
6
DEV2.1/CM1/03_Compteur/Main.java
Normal file
6
DEV2.1/CM1/03_Compteur/Main.java
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Fenetre fenetre = new Fenetre();
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/CM1/03_Compteur/Six.class
Normal file
BIN
DEV2.1/CM1/03_Compteur/Six.class
Normal file
Binary file not shown.
19
DEV2.1/CM1/03_Compteur/Six.java
Normal file
19
DEV2.1/CM1/03_Compteur/Six.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class Six extends JComponent {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paintComponent(Graphics pinceau) {
|
||||||
|
Graphics secondPinceau = pinceau.create();
|
||||||
|
|
||||||
|
if (this.isOpaque()) {
|
||||||
|
secondPinceau.setColor(this.getBackground());
|
||||||
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
Image img = Toolkit.getDefaultToolkit().getImage("6.png");
|
||||||
|
// On place l'image au milieu de son composant puis on soustrait par la moitié des dimensions de l'image (55x80)
|
||||||
|
secondPinceau.drawImage(img, this.getWidth()/2 - 27 , this.getHeight()/2 - 40, this);
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/CM1/04_Illumination/Fenetre.class
Normal file
BIN
DEV2.1/CM1/04_Illumination/Fenetre.class
Normal file
Binary file not shown.
19
DEV2.1/CM1/04_Illumination/Fenetre.java
Normal file
19
DEV2.1/CM1/04_Illumination/Fenetre.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class Fenetre extends JFrame {
|
||||||
|
|
||||||
|
public Fenetre() {
|
||||||
|
this.setSize(300, 400);
|
||||||
|
this.setLocation(100, 100);
|
||||||
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
this.setLayout(new GridLayout(1, 1));
|
||||||
|
|
||||||
|
JPanel fond = new JPanel();
|
||||||
|
fond.setBackground(Color.BLACK);
|
||||||
|
this.add(fond);
|
||||||
|
|
||||||
|
GestionMolette molette = new GestionMolette(fond);
|
||||||
|
this.addMouseWheelListener(molette);
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/CM1/04_Illumination/GestionMolette.class
Normal file
BIN
DEV2.1/CM1/04_Illumination/GestionMolette.class
Normal file
Binary file not shown.
21
DEV2.1/CM1/04_Illumination/GestionMolette.java
Normal file
21
DEV2.1/CM1/04_Illumination/GestionMolette.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import java.awt.event.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class GestionMolette implements MouseWheelListener {
|
||||||
|
|
||||||
|
private JPanel fond;
|
||||||
|
|
||||||
|
public GestionMolette(JPanel fond) {
|
||||||
|
this.fond = fond;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseWheelMoved(MouseWheelEvent evenement) {
|
||||||
|
if (evenement.getWheelRotation() < 0) {
|
||||||
|
this.fond.setBackground(Color.WHITE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.fond.setBackground(Color.BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/CM1/04_Illumination/Main.class
Normal file
BIN
DEV2.1/CM1/04_Illumination/Main.class
Normal file
Binary file not shown.
6
DEV2.1/CM1/04_Illumination/Main.java
Normal file
6
DEV2.1/CM1/04_Illumination/Main.java
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Fenetre fenetre = new Fenetre();
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/TDs/Flux.class
Normal file
BIN
DEV2.1/TDs/Flux.class
Normal file
Binary file not shown.
25
DEV2.1/TDs/Flux.java
Normal file
25
DEV2.1/TDs/Flux.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class Flux {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
FileOutputStream sortie;
|
||||||
|
DataOutputStream flux;
|
||||||
|
float[] tab = {1.0f, 2.0f, 1.5f};
|
||||||
|
try {
|
||||||
|
sortie = new FileOutputStream("reels.bin");
|
||||||
|
flux = new DataOutputStream(sortie);
|
||||||
|
} catch (IOException e1) {
|
||||||
|
}
|
||||||
|
for (float valeur : tab) {
|
||||||
|
try {
|
||||||
|
flux.writeFloat(valeur);
|
||||||
|
} catch (IOException e2) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
flux.close();
|
||||||
|
} catch (IOException e3) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/TDs/reels.bin
Normal file
BIN
DEV2.1/TDs/reels.bin
Normal file
Binary file not shown.
@@ -31,10 +31,6 @@ public class Balle extends JComponent {
|
|||||||
this.pinceau = secondPinceau;
|
this.pinceau = secondPinceau;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearComponent() {
|
|
||||||
this.pinceau.clearRect(0, 0, this.getWidth(), this.getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPosX() {
|
public int getPosX() {
|
||||||
return this.posXImage;
|
return this.posXImage;
|
||||||
}
|
}
|
||||||
|
BIN
DEV2.1/TP11/01_Image/Fenetre.class
Normal file
BIN
DEV2.1/TP11/01_Image/Fenetre.class
Normal file
Binary file not shown.
12
DEV2.1/TP11/01_Image/Fenetre.java
Normal file
12
DEV2.1/TP11/01_Image/Fenetre.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class Fenetre extends JFrame {
|
||||||
|
public Fenetre() {
|
||||||
|
this.setSize(768, 1024);
|
||||||
|
this.setLocation(100, 100);
|
||||||
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
this.setLayout(new GridLayout(1, 1));
|
||||||
|
this.add(new Image());
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/TP11/01_Image/Image.class
Normal file
BIN
DEV2.1/TP11/01_Image/Image.class
Normal file
Binary file not shown.
19
DEV2.1/TP11/01_Image/Image.java
Normal file
19
DEV2.1/TP11/01_Image/Image.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class Image extends JComponent {
|
||||||
|
@Override
|
||||||
|
public void paintComponent(Graphics pinceau) {
|
||||||
|
Graphics secondPinceau = pinceau.create();
|
||||||
|
Color couleur;
|
||||||
|
|
||||||
|
if (this.isOpaque()) {
|
||||||
|
secondPinceau.setColor(this.getBackground());
|
||||||
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
secondPinceau.drawImage(new LectureFichier().getImage(), 0, 0, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/TP11/01_Image/LectureFichier.class
Normal file
BIN
DEV2.1/TP11/01_Image/LectureFichier.class
Normal file
Binary file not shown.
52
DEV2.1/TP11/01_Image/LectureFichier.java
Normal file
52
DEV2.1/TP11/01_Image/LectureFichier.java
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class LectureFichier {
|
||||||
|
|
||||||
|
private BufferedImage image;
|
||||||
|
|
||||||
|
public LectureFichier() {
|
||||||
|
this.image = new BufferedImage(768, 1024, BufferedImage.TYPE_3BYTE_BGR);
|
||||||
|
int r;
|
||||||
|
int g;
|
||||||
|
int b;
|
||||||
|
int i = 0;
|
||||||
|
int j = 0;
|
||||||
|
Color couleur;
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileInputStream fichier = new FileInputStream("image.bin");
|
||||||
|
|
||||||
|
while(fichier.available() >= 3) {
|
||||||
|
try {
|
||||||
|
r = fichier.read();
|
||||||
|
g = fichier.read();
|
||||||
|
b = fichier.read();
|
||||||
|
couleur = new Color(r, g, b);
|
||||||
|
this.image.setRGB(i, j, couleur.getRGB());
|
||||||
|
i++;
|
||||||
|
if (i >= 768) {
|
||||||
|
j++;
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
} catch (IOException e2) {
|
||||||
|
System.out.println("Erreur d'accès");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fichier.close();
|
||||||
|
} catch (IOException e3) {
|
||||||
|
System.out.println("Erreur de fermeture");
|
||||||
|
}
|
||||||
|
} catch (IOException e1) {
|
||||||
|
System.out.println("Erreur d'ouverture");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferedImage getImage() {
|
||||||
|
return this.image;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
BIN
DEV2.1/TP11/01_Image/Main.class
Normal file
BIN
DEV2.1/TP11/01_Image/Main.class
Normal file
Binary file not shown.
6
DEV2.1/TP11/01_Image/Main.java
Normal file
6
DEV2.1/TP11/01_Image/Main.java
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Fenetre fenetre = new Fenetre();
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
1
DEV2.1/TP11/01_Image/couleur.bin
Normal file
1
DEV2.1/TP11/01_Image/couleur.bin
Normal file
File diff suppressed because one or more lines are too long
BIN
DEV2.1/TP11/01_Image/image.bin
Normal file
BIN
DEV2.1/TP11/01_Image/image.bin
Normal file
Binary file not shown.
BIN
DEV2.1/TP11/02_Memoire/FermetureFenetre.class
Normal file
BIN
DEV2.1/TP11/02_Memoire/FermetureFenetre.class
Normal file
Binary file not shown.
99
DEV2.1/TP11/02_Memoire/FermetureFenetre.java
Normal file
99
DEV2.1/TP11/02_Memoire/FermetureFenetre.java
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.awt.event.WindowListener;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class FermetureFenetre implements WindowListener {
|
||||||
|
|
||||||
|
private int fenetreX;
|
||||||
|
private int fenetreY;
|
||||||
|
private JFrame fenetre;
|
||||||
|
|
||||||
|
public FermetureFenetre(JFrame fenetre) {
|
||||||
|
super();
|
||||||
|
this.fenetre = fenetre;
|
||||||
|
this.fenetreX = 300;
|
||||||
|
this.fenetreY = 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void windowActivated(WindowEvent evenement) {
|
||||||
|
|
||||||
|
} // premier plan
|
||||||
|
|
||||||
|
public void windowClosed(WindowEvent evenement) {
|
||||||
|
|
||||||
|
}
|
||||||
|
public void windowClosing(WindowEvent evenement) {
|
||||||
|
try {
|
||||||
|
Dimension dims = this.fenetre.getSize();
|
||||||
|
FileOutputStream fichier = new FileOutputStream("windowlocation.bin");
|
||||||
|
DataOutputStream flux = new DataOutputStream(fichier);
|
||||||
|
|
||||||
|
try {
|
||||||
|
flux.writeInt((int) dims.getWidth());
|
||||||
|
flux.writeInt((int) dims.getHeight());
|
||||||
|
} catch (IOException e2){
|
||||||
|
System.out.println("Erreur d'écriture");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
flux.close();
|
||||||
|
} catch (IOException e3) {
|
||||||
|
System.out.println("Erreur de fermeture");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Erreur d'ouverture");
|
||||||
|
}
|
||||||
|
} // avant fermeture
|
||||||
|
|
||||||
|
public void windowDeactivated(WindowEvent evenement) {
|
||||||
|
|
||||||
|
} // arrière-plan
|
||||||
|
|
||||||
|
public void windowDeiconified(WindowEvent evenement) {
|
||||||
|
|
||||||
|
} // restauration
|
||||||
|
|
||||||
|
public void windowIconified(WindowEvent evenement){
|
||||||
|
|
||||||
|
} // minimisation
|
||||||
|
|
||||||
|
public void windowOpened(WindowEvent evenement) {
|
||||||
|
try {
|
||||||
|
FileInputStream fichier = new FileInputStream("windowlocation.bin");
|
||||||
|
DataInputStream flux = new DataInputStream(fichier);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (flux.available() >= 8) {
|
||||||
|
this.fenetreX = flux.readInt();
|
||||||
|
this.fenetreY = flux.readInt();
|
||||||
|
this.fenetre.setSize(this.fenetreX, this.fenetreY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (IOException e5) {
|
||||||
|
System.out.println("Erreur de lecture");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
flux.close();
|
||||||
|
} catch (IOException e6) {
|
||||||
|
System.out.println("Erreur de fermeture");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e4) {
|
||||||
|
System.out.println("Erreur d'ouverture");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return this.fenetreX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getY() {
|
||||||
|
return this.fenetreY;
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/TP11/02_Memoire/Fond$1.class
Normal file
BIN
DEV2.1/TP11/02_Memoire/Fond$1.class
Normal file
Binary file not shown.
BIN
DEV2.1/TP11/02_Memoire/Fond$2.class
Normal file
BIN
DEV2.1/TP11/02_Memoire/Fond$2.class
Normal file
Binary file not shown.
BIN
DEV2.1/TP11/02_Memoire/Fond$3.class
Normal file
BIN
DEV2.1/TP11/02_Memoire/Fond$3.class
Normal file
Binary file not shown.
BIN
DEV2.1/TP11/02_Memoire/Fond.class
Normal file
BIN
DEV2.1/TP11/02_Memoire/Fond.class
Normal file
Binary file not shown.
46
DEV2.1/TP11/02_Memoire/Fond.java
Normal file
46
DEV2.1/TP11/02_Memoire/Fond.java
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
|
public class Fond {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame fenetre = new JFrame();
|
||||||
|
FermetureFenetre evenementFenetre = new FermetureFenetre(fenetre);
|
||||||
|
fenetre.addWindowListener(evenementFenetre);
|
||||||
|
fenetre.setLocation(100,100);
|
||||||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
fenetre.setLayout(new GridLayout(1, 1));
|
||||||
|
|
||||||
|
JPanel panneau = new JPanel();
|
||||||
|
|
||||||
|
JButton bouton1 = new JButton("Cyan");
|
||||||
|
JButton bouton2 = new JButton("Magenta");
|
||||||
|
JButton bouton3 = new JButton("Jaune");
|
||||||
|
|
||||||
|
bouton1.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent evenement) {
|
||||||
|
panneau.setBackground(Color.CYAN);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bouton2.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent evenement) {
|
||||||
|
panneau.setBackground(Color.MAGENTA);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bouton3.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent evenement) {
|
||||||
|
panneau.setBackground(Color.YELLOW);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
panneau.add(bouton1);
|
||||||
|
panneau.add(bouton2);
|
||||||
|
panneau.add(bouton3);
|
||||||
|
|
||||||
|
fenetre.add(panneau);
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV2.1/TP11/02_Memoire/windowlocation.bin
Normal file
BIN
DEV2.1/TP11/02_Memoire/windowlocation.bin
Normal file
Binary file not shown.
BIN
DEV2.1/TP11/03_Coloriage/EcritureFichier.class
Normal file
BIN
DEV2.1/TP11/03_Coloriage/EcritureFichier.class
Normal file
Binary file not shown.
81
DEV2.1/TP11/03_Coloriage/EcritureFichier.java
Normal file
81
DEV2.1/TP11/03_Coloriage/EcritureFichier.java
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class EcritureFichier {
|
||||||
|
|
||||||
|
private byte r;
|
||||||
|
private byte g;
|
||||||
|
private byte b;
|
||||||
|
|
||||||
|
private byte r2;
|
||||||
|
private byte g2;
|
||||||
|
private byte b2;
|
||||||
|
|
||||||
|
public EcritureFichier(byte r, byte g, byte b) {
|
||||||
|
this.r = r;
|
||||||
|
this.g = g;
|
||||||
|
this.b = b;
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileOutputStream fichier = new FileOutputStream("couleur.bin");
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (int i = 0; i != 768; i++) {
|
||||||
|
for (int j = 0; j != 1024; j++) {
|
||||||
|
fichier.write(r);
|
||||||
|
fichier.write(g);
|
||||||
|
fichier.write(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e2) {
|
||||||
|
System.out.println("Erreur d'écriture");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fichier.close();
|
||||||
|
} catch (IOException e3) {
|
||||||
|
System.out.println("Erreur de fermeture");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Erreur d'ouverture");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EcritureFichier(byte r, byte g, byte b, byte r2, byte g2, byte b2) {
|
||||||
|
this.r = r;
|
||||||
|
this.g = g;
|
||||||
|
this.b = b;
|
||||||
|
this.r2 = r2;
|
||||||
|
this.g2 = g2;
|
||||||
|
this.b2 = b2;
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileOutputStream fichier = new FileOutputStream("couleur.bin");
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (int i = 0; i != 768; i++) {
|
||||||
|
for (int j = 0; j != 1024; j++) {
|
||||||
|
fichier.write(r);
|
||||||
|
fichier.write(g);
|
||||||
|
fichier.write(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e2) {
|
||||||
|
System.out.println("Erreur d'écriture");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fichier.close();
|
||||||
|
} catch (IOException e3) {
|
||||||
|
System.out.println("Erreur de fermeture");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Erreur d'ouverture");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
BIN
DEV2.1/TP11/03_Coloriage/Main.class
Normal file
BIN
DEV2.1/TP11/03_Coloriage/Main.class
Normal file
Binary file not shown.
11
DEV2.1/TP11/03_Coloriage/Main.java
Normal file
11
DEV2.1/TP11/03_Coloriage/Main.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
String chaineCouleur = args[0].replaceAll("#", "");
|
||||||
|
Integer r = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(0, 2), 16));
|
||||||
|
Integer g = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(2, 4), 16));
|
||||||
|
Integer b = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(4, 6), 16));
|
||||||
|
EcritureFichier ecriture = new EcritureFichier(r.byteValue(), g.byteValue(), b.byteValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
DEV2.1/TP11/03_Coloriage/couleur.bin
Normal file
1
DEV2.1/TP11/03_Coloriage/couleur.bin
Normal file
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -1,21 +0,0 @@
|
|||||||
import java.awt.*;
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.event.*;
|
|
||||||
|
|
||||||
public class Acharnement extends WindowAdapter{
|
|
||||||
|
|
||||||
private int compteur;
|
|
||||||
|
|
||||||
public Acharnement() {
|
|
||||||
this.compteur = 0;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void windowClosing(WindowEvent evenement) {
|
|
||||||
if (this.compteur == 2) {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.compteur++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user