This commit is contained in:
EmmanuelTiamzon
2025-09-30 09:43:41 +02:00
parent f7de13bc2a
commit 7019a3b7ea
176 changed files with 9458 additions and 149 deletions

Binary file not shown.

View File

@@ -1,6 +1,5 @@
public class MainArtihmetic {
public void main(String[] args) {
String truc = "abc";
System.out.println(Integer.parse.Int(truc));
public class MainArithmetic {
public static void main(String[] args) {
System.out.println(15/0);
}
}

View File

@@ -0,0 +1,15 @@
public class Capture {
public static int ArithmeticPB(int val) {
return val/0;
}
public static void main(String[] args) {
try {
int res = ArithmeticPB(5);
System.out.println(res);
} catch(ArithmeticException e) {
System.err.println("cannot divide by 0");
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,6 @@
public class Incomplet {
public static void main(String[] args) {
byte[] txt = {0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x0D, 0x0A};
System.out.print(new String(txt));
}
}

View File

@@ -0,0 +1,9 @@
public class Conversion {
public static double celsiusAFahrenheit(double n) {
return n*9/5+32;
}
public static double FahrenheitACelsius(double n) {
return (n-32)*5/9;
}
}

View File

@@ -0,0 +1,38 @@
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class Degres 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());
}
secondPinceau.setColor(Color.ORANGE);
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
JTextField celsius = new JTextField();
JTextField fahrenheit = new JTextField();
celsius.setBounds(0, 65, 160, 20);
fahrenheit.setBounds(0, 90, 160, 20);
JLabel texteCelsius = new JLabel("°C");
JLabel texteFahrenheit = new JLabel("°F");
texteCelsius.setBounds(165, 65, 20, 20);
texteFahrenheit.setBounds(165, 90, 20, 20);
celsius.getDocument().addDocumentListener(new GestionJTextField(celsius, fahrenheit, true));
fahrenheit.getDocument().addDocumentListener(new GestionJTextField(fahrenheit, celsius, false));
this.add(celsius);
this.add(fahrenheit);
this.add(texteCelsius);
this.add(texteFahrenheit);
}
}

View File

@@ -0,0 +1,46 @@
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class GestionJTextField implements DocumentListener {
private JTextField aConvertir;
private JTextField convertirVers;
private boolean cToF;
public GestionJTextField(JTextField aConvertir, JTextField convertirVers, boolean cToF) {
this.aConvertir = aConvertir;
this.convertirVers = convertirVers;
this.cToF = cToF;
}
public void changedUpdate(DocumentEvent e) {
}
public void insertUpdate(DocumentEvent e) {
try {
if (this.cToF) {
this.convertirVers.setText(Conversion.celsiusAFahrenheit(Double.parseDouble(this.aConvertir.getText())) + "");
}
else {
this.convertirVers.setText(Conversion.FahrenheitACelsius(Double.parseDouble(this.aConvertir.getText())) + "");
}
} catch (NumberFormatException e2) {
try {
this.convertirVers.setText("???");
} catch (IllegalStateException ee) {
}
} catch (IllegalStateException e3) {
} finally {
this.convertirVers.repaint();
}
}
public void removeUpdate(DocumentEvent e) {
}
}

View 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());
}
}

View 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);
}
}

View 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("couleur.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;
}
}

View File

@@ -0,0 +1,6 @@
public class Main {
public static void main(String[] args) {
Fenetre fenetre = new Fenetre();
fenetre.setVisible(true);
}
}

Binary file not shown.

Binary file not shown.

View 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;
}
}

View 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);
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,108 @@
import java.awt.*;
import java.io.*;
public class EcritureFichier {
private int r;
private int g;
private int b;
private int r2;
private int g2;
private int b2;
public EcritureFichier(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
try {
FileOutputStream fichier = new FileOutputStream("couleur.bin");
System.out.println(r + " " + g + " " + b);
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(int r, int g, int b, int r2, int g2, int 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");
int choixR = r;
int choixG = g;
int choixB = b;
try {
for (int l = 0; l != 8; l++) {
for (int k = 0; k != 8; k++) {
for (int i = 0; i != 768/8; i++) {
for (int j = 0; j != 1024/8; j++) {
fichier.write(choixR);
fichier.write(choixG);
fichier.write(choixB);
}
if (choixR == r) {
choixR = r2;
choixG = g2;
choixB = b2;
}
else {
choixR = r;
choixG = g;
choixB = b;
}
}
}
if (choixR == r) {
choixR = r2;
choixG = g2;
choixB = b2;
}
else {
choixR = r;
choixG = g;
choixB = 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");
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,21 @@
public class Main {
public static void main(String[] args) {
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));
if (args.length == 1) {
EcritureFichier ecriture = new EcritureFichier(r, g, b);
}
else if (args.length == 2) {
String chaineCouleur2 = args[1].replaceAll("#", "");
Integer r2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(0, 2), 16));
Integer g2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(2, 4), 16));
Integer b2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(4, 6), 16));
System.out.println(r + "," + g + "," + b + " | " + r2 + "," + g2 + "," + b2);
EcritureFichier ecriture2 = new EcritureFichier(r, g, b, r2, g2, b2);
}
}
}

View File

@@ -0,0 +1,97 @@
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 JPanel panneau;
private JFrame fenetre;
public FermetureFenetre(JFrame fenetre, JPanel panneau) {
super();
this.fenetre = fenetre;
this.panneau = panneau;
}
public void windowActivated(WindowEvent evenement) {
} // premier plan
public void windowClosed(WindowEvent evenement) {
}
public void windowClosing(WindowEvent evenement) {
try {
Dimension dims = this.fenetre.getSize();
Point loc = this.fenetre.getLocation();
Color color = this.panneau.getBackground();
FileOutputStream fichier = new FileOutputStream("windowlocation.bin");
DataOutputStream flux = new DataOutputStream(fichier);
try {
flux.writeInt((int) loc.getX());
flux.writeInt((int) loc.getY());
flux.writeInt((int) dims.getWidth());
flux.writeInt((int) dims.getHeight());
flux.writeInt(color.getRed());
flux.writeInt(color.getGreen());
flux.writeInt(color.getBlue());
} 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() >= 28) {
this.fenetre.setLocation(flux.readInt(), flux.readInt());
this.fenetre.setSize(flux.readInt(), flux.readInt());
this.panneau.setBackground(new Color(flux.readInt(), flux.readInt(), flux.readInt()));
System.out.println(this.panneau.getBackground() + "");
}
} 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");
}
}
}

View 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();
JPanel panneau = new JPanel();
FermetureFenetre evenementFenetre = new FermetureFenetre(fenetre, panneau);
fenetre.addWindowListener(evenementFenetre);
fenetre.setLocation(100,100);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setLayout(new GridLayout(1, 1));
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);
}
}

Binary file not shown.

View File

@@ -0,0 +1,16 @@
import java.awt.*;
import javax.swing.*;
public class Fenetre extends JFrame {
public Fenetre() {
this.setSize(500, 600);
this.setLocation(100, 100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridLayout(1, 1));
LectureFichier lecture = new LectureFichier();
EcritureFichier ecriture = new EcritureFichier("test", lecture.getCoordY(), lecture.getNbPoints());
this.add(new Polygone(lecture.getCoordX(), lecture.getCoordY(), lecture.getNbPoints()));
EcritureFichier ecriture = new EcritureFichier(lecture.getCoordX(), lecture.getCoordY(), lecture.getNbPoints());
}
}

View File

@@ -0,0 +1,54 @@
import java.awt.*;
import java.io.*;
public class LectureFichier {
private int[] coordX;
private int[] coordY;
private int nbPoints;
public LectureFichier() {
try {
FileInputStream fichier = new FileInputStream("polygone.bin");
DataInputStream flux = new DataInputStream(fichier);
this.coordX = new int[flux.available()/8];
this.coordY = new int[flux.available()/8];
this.nbPoints = flux.available()/8;
int compteur = 0;
try {
while (flux.available() > 0) {
this.coordX[compteur] = flux.readInt();
this.coordY[compteur] = flux.readInt();
compteur++;
}
} catch (IOException e2) {
System.out.println("Erreur de lecture");
}
try {
flux.close();
} catch (IOException e3) {
System.out.println("Erreur de fermeture");
}
} catch (IOException e) {
System.out.println("Erreur d'ouverture");
}
}
public int[] getCoordX() {
return this.coordX;
}
public int[] getCoordY() {
return this.coordY;
}
public int getNbPoints() {
return this.nbPoints;
}
}

View File

@@ -0,0 +1,6 @@
public class Main {
public static void main(String[] args) {
Fenetre fenetre = new Fenetre();
fenetre.setVisible(true);
}
}

View File

@@ -0,0 +1,28 @@
import java.awt.*;
import javax.swing.*;
public class Polygone extends JComponent {
private int[] coordX;
private int[] coordY;
private int nbPoints;
public Polygone(int[] coordX, int[] coordY, int nbPoints) {
this.coordX = coordX;
this.coordY = coordY;
this.nbPoints = nbPoints;
}
@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());
}
secondPinceau.setColor(Color.BLUE);
secondPinceau.fillPolygon(this.coordX, this.coordY, this.nbPoints);
}
}

View File

@@ -0,0 +1,47 @@
import java.awt.*;
import java.io.*;
public class EcritureFichier {
private int[] coordX;
private int[] coordY;
private int nbPoints;
private boolean aMultiplier;
public EcritureFichier(int[] coordX, int[] coordY, int nbPoints, boolean aMultiplier) {
this.coordX = coordX;
this.coordY = coordY;
this.nbPoints = nbPoints;
this.aMultiplier = aMultiplier;
try {
FileOutputStream fichier = new FileOutputStream("polygone.bin");
DataOutputStream flux = new DataOutputStream(fichier);
try{
for (int i = 0; i != nbPoints; i++) {
if (this.aMultiplier) {
flux.writeInt(this.coordX[i]*2);
flux.writeInt(this.coordY[i]*2);
}
else {
flux.writeInt(this.coordX[i]/2);
flux.writeInt(this.coordY[i]/2);
}
}
} catch (IOException e2) {
System.out.println("Erreur d'écriture");
}
try {
flux.close();
System.out.println("Fin de l'écriture");
} catch (IOException e3) {
System.out.println("Erreur de fermeture");
}
} catch (IOException e) {
System.out.println("Erreur d'ouverture");
}
}
}

View File

@@ -0,0 +1,15 @@
import java.awt.*;
import javax.swing.*;
public class Fenetre extends JFrame {
public Fenetre(boolean aMultiplier) {
this.setSize(500, 600);
this.setLocation(100, 100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridLayout(1, 1));
LectureFichier lecture = new LectureFichier();
this.add(new Polygone(lecture.getCoordX(), lecture.getCoordY(), lecture.getNbPoints()));
EcritureFichier ecriture = new EcritureFichier(lecture.getCoordX(), lecture.getCoordY(), lecture.getNbPoints(), aMultiplier);
}
}

View File

@@ -0,0 +1,54 @@
import java.awt.*;
import java.io.*;
public class LectureFichier {
private int[] coordX;
private int[] coordY;
private int nbPoints;
public LectureFichier() {
try {
FileInputStream fichier = new FileInputStream("polygone.bin");
DataInputStream flux = new DataInputStream(fichier);
this.coordX = new int[flux.available()/8];
this.coordY = new int[flux.available()/8];
this.nbPoints = flux.available()/8;
int compteur = 0;
try {
while (flux.available() > 0) {
this.coordX[compteur] = flux.readInt();
this.coordY[compteur] = flux.readInt();
compteur++;
}
} catch (IOException e2) {
System.out.println("Erreur de lecture");
}
try {
flux.close();
} catch (IOException e3) {
System.out.println("Erreur de fermeture");
}
} catch (IOException e) {
System.out.println("Erreur d'ouverture");
}
}
public int[] getCoordX() {
return this.coordX;
}
public int[] getCoordY() {
return this.coordY;
}
public int getNbPoints() {
return this.nbPoints;
}
}

View File

@@ -0,0 +1,14 @@
public class Main {
public static void main(String[] args) {
Fenetre fenetre;
try {
if (args[0].equals("diviser")) {
fenetre = new Fenetre(false);
}
else {
fenetre = new Fenetre(true);
}
} catch (ArrayIndexOutOfBoundsException e) {
}
}
}

View File

@@ -0,0 +1,28 @@
import java.awt.*;
import javax.swing.*;
public class Polygone extends JComponent {
private int[] coordX;
private int[] coordY;
private int nbPoints;
public Polygone(int[] coordX, int[] coordY, int nbPoints) {
this.coordX = coordX;
this.coordY = coordY;
this.nbPoints = nbPoints;
}
@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());
}
secondPinceau.setColor(Color.BLUE);
secondPinceau.fillPolygon(this.coordX, this.coordY, this.nbPoints);
}
}

Binary file not shown.

View File

@@ -0,0 +1,50 @@
import java.awt.*;
import java.io.*;
import java.util.Random;
public class Main {
public static void main(String[] args) {
Random aleatoire = new Random();
int aDeviner = aleatoire.nextInt(100) + 1;
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
String essai = "-1";
try {
System.out.println("Essai n°1 : Veuillez entrer un nombre (1 à 100) : ");
essai = console.readLine();
} catch (IOException e) {
System.err.println("Erreur de console.");
}
try {
for (int i = 2; i != 6; i++) {
if (Integer.parseInt(essai) > aDeviner) {
System.out.println("-");
}
else if (Integer.parseInt(essai) == aDeviner) {
break;
}
else {
System.out.println("+");
}
System.out.println("Essai n°" + i + " : Veuillez entrer un nombre (1 à 100) : ");
essai = console.readLine();
}
if (Integer.parseInt(essai) == aDeviner) {
System.out.println("Nombre trouvé.");
}
else {
System.out.println("Nombre non trouvé après 5 essais.");
}
} catch (IOException e) {
System.err.println("Erreur de console.");
} catch (NumberFormatException e2) {
System.err.println("Veuillez n'entrer que des nombres.");
}
}
}

View File

@@ -0,0 +1,12 @@
import java.awt.*;
import javax.swing.*;
public class Fenetre extends JFrame {
public Fenetre() {
this.setSize(32, 35);
this.setLocation(100, 100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridLayout(1, 1));
this.add(new Image());
}
}

View File

@@ -0,0 +1,13 @@
import java.awt.*;
import javax.swing.*;
public class Image extends JComponent {
@Override
public void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
LectureFichier fichier = new LectureFichier();
secondPinceau.drawImage(fichier.getImage(), 0, 0, this);
}
}

View File

@@ -0,0 +1,74 @@
import java.awt.*;
import java.io.*;
import java.awt.image.BufferedImage;
public class LectureFichier {
private BufferedImage image;
public LectureFichier() {
try {
BufferedReader lecture = new BufferedReader(new FileReader("image.xpm"));
try {
for (int i = 0; i != 3; i++) {
lecture.readLine();
}
String infos = lecture.readLine();
infos = infos.replaceAll("\"", "");
String[] infosTab = infos.split(" ");
for (String info : infosTab) {
System.out.println(info);
}
this.image = new BufferedImage(Integer.parseInt(infosTab[0]), Integer.parseInt(infosTab[1]), BufferedImage.TYPE_3BYTE_BGR);
char[] caracteres = new char[15];
Color[] couleurs = new Color[15];
for (int i = 0; i != Integer.parseInt(infosTab[2]); i++) {
String ligne = lecture.readLine();
caracteres[i] = ligne.charAt(1);
int[] rgb = {
Integer.parseInt(ligne.substring(6,8), 16),
Integer.parseInt(ligne.substring(8,10), 16),
Integer.parseInt(ligne.substring(10,12), 16)
};
couleurs[i] = new Color(rgb[0], rgb[1], rgb[2]);
}
lecture.readLine();
for (int i = 0; i != Integer.parseInt(infosTab[1]); i++) {
String ligne = lecture.readLine().replaceAll("\"", "");
ligne = ligne.substring(0, ligne.length()-1);
for (int j = 0; j != ligne.length(); j++) {
for (int k = 0; k != caracteres.length; k++) {
if (caracteres[k] == ligne.charAt(j)) {
this.image.setRGB(i, j, couleurs[k].getRGB());
}
}
}
}
} catch (IOException e2) {
System.err.println("Erreur d'écriture");
}
try {
lecture.close();
} catch (IOException e3) {
System.err.println("Erreur de fermeture");
}
} catch (IOException e1) {
System.err.println("Erreur d'ouverture");
}
}
public BufferedImage getImage() {
return this.image;
}
}

View File

@@ -0,0 +1,6 @@
public class Main {
public static void main(String[] args) {
Fenetre fenetre = new Fenetre();
fenetre.setVisible(true);
}
}

View File

@@ -0,0 +1,56 @@
/* XPM */
static char *test[] = {
/* columns rows colors chars-per-pixel */
"32 35 15 1",
" c #000000",
". c #731810",
"X c #A52918",
"o c #FF5210",
"O c #D64221",
"+ c #FF8C10",
"@ c #FFBD29",
"# c #FFE739",
"$ c #FFBD4A",
"% c #FFFF63",
"& c #9C8C8C",
"* c #C6B5B5",
"= c #B0D8D0",
"- c #EFDEDE",
"; c #FFFFFF",
/* pixels */
"================================",
"================================",
"=============O====o=============",
"==============O==o#o============",
"==============oO=o@o============",
"==============ooOo+o============",
"==========o===o+o=o=============",
"=========o@o=Oo++o==============",
"=========ooo=o+@+o==============",
"==========o=O++@+oO=============",
"============o+@#@o+O============",
"===========O+@#;#+@+o===========",
"===========O+#;;;+#@o===========",
"===========o@;;;;@#o============",
"=== =======..........======= ===",
"== = = ==..XXOOooOOXX..== = = ==",
"= = =.XXoOO OOoXX.= = =",
"== XXXX % % XXXX ==",
"=== oX XXX XXX Xo ===",
"=====X o$X -& &- X$o X=====",
"=====X o$$o ;;;;;; o$$o X=====",
"===== Xoo$$$ -;oo;- $$$ooX =====",
"===== OoX$Xoo ;;;; ooX$XoO =====",
"===== Xo o O -;;- O o oX =====",
"====== O O = -- = O O ======",
"======= = *= o o =* = =======",
"=========== * oooo * ===========",
"=========== oooooo ===========",
"========== XooooooX ==========",
"========= X XooooooX X =========",
"========= OooOOOOOOooO =========",
"========== oooooooo ==========",
"============ ============",
"================================",
"================================"
};

View File

@@ -0,0 +1,5 @@
public class Questionnaire {
public Questionnaire() {
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -6,7 +6,7 @@ public class Formes extends JComponent {
public Formes() {
super();
this.img = Toolkit.getDefaultToolkit().getImage("img.png");
this.img = Toolkit.getDefaultToolkit().getImage("../2.Sautoir/img.png");
}
@Override

Binary file not shown.

View File

@@ -0,0 +1,30 @@
import java.awt.*;
import javax.swing.*;
public class Cercle extends JComponent {
private Color fond;
public Cercle(Color fond) {
this.fond = fond;
}
@Override
public void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
if (this.isOpaque()) {
pinceau.setColor(this.getBackground());
pinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
pinceau.setColor(Color.DARK_GRAY);
pinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
pinceau.setColor(this.fond);
pinceau.fillOval(this.getWidth()/4, this.getHeight()/4, this.getWidth()/2, this.getHeight()/2);
}
public void setFond(Color n) {
this.fond = n;
}
}

View File

@@ -0,0 +1,29 @@
import java.awt.*;
import javax.swing.*;
public class Fenetre extends JFrame {
public Fenetre() {
this.setSize(700, 100);
this.setLocation(100, 100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridLayout(1, 10));
Cercle[] tabCercles = new Cercle[10];
for (int i = 0; i != 5; i++) {
Cercle nouveauCercle = new Cercle(Color.ORANGE);
this.add(nouveauCercle);
tabCercles[i] = nouveauCercle;
}
for (int i = 5; i != 10; i++) {
Cercle nouveauCercle = new Cercle(Color.LIGHT_GRAY);
this.add(nouveauCercle);
tabCercles[i] = nouveauCercle;
}
MoletteSouris gestionSouris = new MoletteSouris(this, tabCercles);
this.addMouseWheelListener(gestionSouris);
}
}

View File

@@ -1,16 +0,0 @@
import javax.swing.*;
import java.awt.*;
public class Mafenetre extends JFrame {
public Mafenetre() {
super("Volume");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(697,156);
this.setLocation(500,250);
Volume volume = new Volume();
this.add(volume);
}
}

View File

@@ -0,0 +1,6 @@
public class Main {
public static void main(String[] args) {
Fenetre fenetre = new Fenetre();
fenetre.setVisible(true);
}
}

Some files were not shown because too many files have changed in this diff Show More