diff --git a/DEV2.1/TP06/Test.class b/DEV2.1/TP06/Test.class new file mode 100644 index 0000000..fdab46b Binary files /dev/null and b/DEV2.1/TP06/Test.class differ diff --git a/DEV2.1/TP06/Test.java b/DEV2.1/TP06/Test.java new file mode 100644 index 0000000..0e70905 --- /dev/null +++ b/DEV2.1/TP06/Test.java @@ -0,0 +1,19 @@ +import java.awt.*; +import javax.swing.*; + +public class Test { + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + fenetre.setSize(300, 200); + fenetre.setLocation(100, 100); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JLabel texte = new JLabel("L'alcool c'est pas bien"); + texte.setHorizontalAlignment(JLabel.CENTER); + texte.setFont(new Font("Arial", Font.BOLD, 35)); + fenetre.setLayout(new BorderLayout()); + fenetre.add(texte, BorderLayout.CENTER); + fenetre.setVisible(true); + + } +} \ No newline at end of file diff --git a/DEV2.1/TP07/Etoile.java b/DEV2.1/TP07/Etoile.java index 009adde..bd3de36 100644 --- a/DEV2.1/TP07/Etoile.java +++ b/DEV2.1/TP07/Etoile.java @@ -1,6 +1,7 @@ -import java.awt.Point; +import java.awt.*; +import javax.swing.*; -public class Etoile implements ProducteurDePoints { +public class Etoile implements ProducteurDePoints extends JComponent { private static final int xCentre = 100; private static final int yCentre = 100; private static final double rayon = 90.0; @@ -24,7 +25,22 @@ public class Etoile implements ProducteurDePoints { return p; } + @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.drawRect(); + } + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + fenetre.setSize(300, 300); + fenetre.setLocation(100, 100); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + fenetre.setVisible(true); Etoile e = new Etoile(); while (e.suivant() != null) { // TODO diff --git a/DEV2.1/TP07/Vehicule.java b/DEV2.1/TP07/Vehicule.java index f7604d5..81c672d 100644 --- a/DEV2.1/TP07/Vehicule.java +++ b/DEV2.1/TP07/Vehicule.java @@ -1,5 +1,4 @@ public interface Vehicule { - public String sorte(); public int nbRoues(); diff --git a/DEV2.1/TP08/Attente.class b/DEV2.1/TP08/Attente.class new file mode 100644 index 0000000..5fd5e28 Binary files /dev/null and b/DEV2.1/TP08/Attente.class differ diff --git a/DEV2.1/TP08/Attente.java b/DEV2.1/TP08/Attente.java new file mode 100644 index 0000000..c8132bf --- /dev/null +++ b/DEV2.1/TP08/Attente.java @@ -0,0 +1,35 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.*; + +public class Attente { + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + fenetre.setSize(300,200); + fenetre.setLocation(100,100); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + fenetre.setLayout(new GridLayout(1, 1)); + + JPanel panneau = new JPanel(); + + + panneau.setLayout(new BorderLayout()); + panneau.setBackground(Color.GREEN); + FenetreListener listener = new FenetreListener(); + fenetre.addWindowListener(listener); + fenetre.add(panneau); + + if (listener.getEstActive()) { + System.out.println("Fenetre activée"); + panneau.add(new CercleMagenta()); + fenetre.repaint(); + } + else { + System.out.println("Fenetre désactivée"); + panneau.add(new Sautoir()); + fenetre.repaint(); + } + + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP08/CercleMagenta.class b/DEV2.1/TP08/CercleMagenta.class new file mode 100644 index 0000000..f648e14 Binary files /dev/null and b/DEV2.1/TP08/CercleMagenta.class differ diff --git a/DEV2.1/TP08/CercleMagenta.java b/DEV2.1/TP08/CercleMagenta.java new file mode 100644 index 0000000..ade6357 --- /dev/null +++ b/DEV2.1/TP08/CercleMagenta.java @@ -0,0 +1,19 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +public class CercleMagenta extends JComponent { + @Override + public void paintComponent(Graphics pinceau) { + Graphics secondPinceau = pinceau.create(); + + if (this.isOpaque()) { + secondPinceau.setColor(this.getBackground()); + secondPinceau.drawRect(0, 0, this.getWidth(), this.getHeight()); + } + + secondPinceau.setColor(Color.MAGENTA); + secondPinceau.fillOval(0, 0, this.getWidth(), this.getHeight()); + } +} \ No newline at end of file diff --git a/DEV2.1/TP08/FenetreListener.class b/DEV2.1/TP08/FenetreListener.class new file mode 100644 index 0000000..42b03fc Binary files /dev/null and b/DEV2.1/TP08/FenetreListener.class differ diff --git a/DEV2.1/TP08/FenetreListener.java b/DEV2.1/TP08/FenetreListener.java new file mode 100644 index 0000000..5cfc123 --- /dev/null +++ b/DEV2.1/TP08/FenetreListener.java @@ -0,0 +1,28 @@ +import java.awt.event.*; +import javax.swing.*; + +public class FenetreListener extends WindowAdapter { + + private boolean estActive; + + public FenetreListener() { + this.estActive = true; + } + + public boolean getEstActive() { + return this.estActive; + } + + + @Override + public void windowActivated(WindowEvent e) { + this.estActive = true; + } + + @Override + public void windowDeactivated(WindowEvent e) { + this.estActive = false; + } + + +} \ No newline at end of file diff --git a/DEV2.1/TP08/Fond$1.class b/DEV2.1/TP08/Fond$1.class new file mode 100644 index 0000000..03c37e4 Binary files /dev/null and b/DEV2.1/TP08/Fond$1.class differ diff --git a/DEV2.1/TP08/Fond$2.class b/DEV2.1/TP08/Fond$2.class new file mode 100644 index 0000000..ebbe02e Binary files /dev/null and b/DEV2.1/TP08/Fond$2.class differ diff --git a/DEV2.1/TP08/Fond$3.class b/DEV2.1/TP08/Fond$3.class new file mode 100644 index 0000000..6344d4f Binary files /dev/null and b/DEV2.1/TP08/Fond$3.class differ diff --git a/DEV2.1/TP08/Fond.class b/DEV2.1/TP08/Fond.class new file mode 100644 index 0000000..d468e33 Binary files /dev/null and b/DEV2.1/TP08/Fond.class differ diff --git a/DEV2.1/TP08/Fond.java b/DEV2.1/TP08/Fond.java new file mode 100644 index 0000000..ffcf242 --- /dev/null +++ b/DEV2.1/TP08/Fond.java @@ -0,0 +1,45 @@ +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(); + fenetre.setSize(300,200); + 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); + } +} \ No newline at end of file diff --git a/DEV2.1/TP08/Sautoir.class b/DEV2.1/TP08/Sautoir.class new file mode 100644 index 0000000..4259a53 Binary files /dev/null and b/DEV2.1/TP08/Sautoir.class differ diff --git a/DEV2.1/TP08/Sautoir.java b/DEV2.1/TP08/Sautoir.java new file mode 100644 index 0000000..ae72164 --- /dev/null +++ b/DEV2.1/TP08/Sautoir.java @@ -0,0 +1,38 @@ +import java.awt.*; +import javax.swing.*; + +public class Sautoir extends JComponent { + + @Override + protected void paintComponent(Graphics pinceau) { + // obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard + Graphics secondPinceau = pinceau.create(); + // obligatoire : si le composant n'est pas censé être transparent + if (this.isOpaque()) { + // obligatoire : on repeint toute la surface avec la couleur de fond + secondPinceau.setColor(this.getBackground()); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + + int[] coord_x = {0, this.getWidth(), 0, this.getWidth()}; + int[] coord_y = {0, 0, this.getHeight(), this.getHeight()}; + Polygon p = new Polygon(coord_x, coord_y, 4); + secondPinceau.setColor(Color.CYAN); + secondPinceau.fillPolygon(p); + + } + + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + GridLayout layout = new GridLayout(5, 5); + // on configure la fenetre + fenetre.setSize(250, 250); + fenetre.setLocation(0, 0); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + fenetre.setLayout(layout); + for (int i = 0; i != 25; i++) { + fenetre.add(new Sautoir()); + } + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/01_Volume/Cercle.class b/DEV2.1/TP09/01_Volume/Cercle.class new file mode 100644 index 0000000..b1f0ee8 Binary files /dev/null and b/DEV2.1/TP09/01_Volume/Cercle.class differ diff --git a/DEV2.1/TP09/01_Volume/Cercle.java b/DEV2.1/TP09/01_Volume/Cercle.java new file mode 100644 index 0000000..774f004 --- /dev/null +++ b/DEV2.1/TP09/01_Volume/Cercle.java @@ -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; + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/01_Volume/Fenetre.class b/DEV2.1/TP09/01_Volume/Fenetre.class new file mode 100644 index 0000000..ee9b90a Binary files /dev/null and b/DEV2.1/TP09/01_Volume/Fenetre.class differ diff --git a/DEV2.1/TP09/01_Volume/Fenetre.java b/DEV2.1/TP09/01_Volume/Fenetre.java new file mode 100644 index 0000000..722f51f --- /dev/null +++ b/DEV2.1/TP09/01_Volume/Fenetre.java @@ -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); + } + +} \ No newline at end of file diff --git a/DEV2.1/TP09/01_Volume/Main.class b/DEV2.1/TP09/01_Volume/Main.class new file mode 100644 index 0000000..4bfefb8 Binary files /dev/null and b/DEV2.1/TP09/01_Volume/Main.class differ diff --git a/DEV2.1/TP09/01_Volume/Main.java b/DEV2.1/TP09/01_Volume/Main.java new file mode 100644 index 0000000..2768c3d --- /dev/null +++ b/DEV2.1/TP09/01_Volume/Main.java @@ -0,0 +1,6 @@ +public class Main { + public static void main(String[] args) { + Fenetre fenetre = new Fenetre(); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/01_Volume/MoletteSouris.class b/DEV2.1/TP09/01_Volume/MoletteSouris.class new file mode 100644 index 0000000..6ae8710 Binary files /dev/null and b/DEV2.1/TP09/01_Volume/MoletteSouris.class differ diff --git a/DEV2.1/TP09/01_Volume/MoletteSouris.java b/DEV2.1/TP09/01_Volume/MoletteSouris.java new file mode 100644 index 0000000..6ccddd9 --- /dev/null +++ b/DEV2.1/TP09/01_Volume/MoletteSouris.java @@ -0,0 +1,38 @@ +import java.awt.event.*; +import java.awt.*; +import javax.swing.*; + +public class MoletteSouris implements MouseWheelListener { + + private Fenetre fenetre; + private Cercle[] tabCercles; + private int depart; + + public MoletteSouris(Fenetre fenetre, Cercle[] tabCercles) { + this.fenetre = fenetre; + this.tabCercles = tabCercles; + this.depart = 5; + } + + @Override + public void mouseWheelMoved(MouseWheelEvent evenement) { + int sensRotation = evenement.getWheelRotation(); + this.depart -= sensRotation; + + if (this.depart == 11) { + this.depart = 10; + } + else if (this.depart == -1) { + this.depart = 0; + } + + for (int i = 0; i < this.depart ; i++) { + this.tabCercles[i].setFond(Color.ORANGE); + } + for (int i = this.depart; i < 10; i++) { + this.tabCercles[i].setFond(Color.LIGHT_GRAY); + } + this.fenetre.repaint(); + + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/02_Playlist/Fenetre.class b/DEV2.1/TP09/02_Playlist/Fenetre.class new file mode 100644 index 0000000..0125b32 Binary files /dev/null and b/DEV2.1/TP09/02_Playlist/Fenetre.class differ diff --git a/DEV2.1/TP09/02_Playlist/Fenetre.java b/DEV2.1/TP09/02_Playlist/Fenetre.java new file mode 100644 index 0000000..240e8c3 --- /dev/null +++ b/DEV2.1/TP09/02_Playlist/Fenetre.java @@ -0,0 +1,34 @@ +import java.awt.*; +import javax.swing.*; + +public class Fenetre extends JFrame { + public Fenetre() { + this.setLocation(100, 100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLayout(new GridLayout(14, 1)); + + JLabel[] chromakopia = { + new JLabel("St. Chroma"), + new JLabel("Rah Tah Tah"), + new JLabel("Noid"), + new JLabel("Darling, I"), + new JLabel("Hey Jane"), + new JLabel("I Killed You"), + new JLabel("Judge Judy"), + new JLabel("Sticky"), + new JLabel("Take Your Mask Off"), + new JLabel("Tomorrow"), + new JLabel("Thought I Was Dead"), + new JLabel("Like Him"), + new JLabel("Balloon"), + new JLabel("I Hope You Find Your Way Home") + }; + + for (JLabel titre : chromakopia) { + this.addMouseListener(new GestionSouris(titre)); + this.add(titre); + } + + this.pack(); + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/02_Playlist/GestionSouris.class b/DEV2.1/TP09/02_Playlist/GestionSouris.class new file mode 100644 index 0000000..3be87e7 Binary files /dev/null and b/DEV2.1/TP09/02_Playlist/GestionSouris.class differ diff --git a/DEV2.1/TP09/02_Playlist/GestionSouris.java b/DEV2.1/TP09/02_Playlist/GestionSouris.java new file mode 100644 index 0000000..895b7dc --- /dev/null +++ b/DEV2.1/TP09/02_Playlist/GestionSouris.java @@ -0,0 +1,33 @@ +import java.awt.event.*; +import javax.swing.*; +import java.awt.*; + +public class GestionSouris implements MouseListener { + + private JLabel titre; + + public GestionSouris(JLabel titre) { + this.titre = titre; + } + + public void mouseClicked(MouseEvent evenement) { + } + + public void mouseEntered(MouseEvent evenement){ + this.titre.setOpaque(true); + this.titre.setBackground(Color.CYAN); + this.titre.repaint(); + } + + public void mouseExited(MouseEvent evenement){ + this.titre.setOpaque(true); + this.titre.setBackground(Color.WHITE); + this.titre.repaint(); + } + + public void mousePressed(MouseEvent evenement){ + } + + public void mouseReleased(MouseEvent evenement){ + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/02_Playlist/Main.class b/DEV2.1/TP09/02_Playlist/Main.class new file mode 100644 index 0000000..4bfefb8 Binary files /dev/null and b/DEV2.1/TP09/02_Playlist/Main.class differ diff --git a/DEV2.1/TP09/02_Playlist/Main.java b/DEV2.1/TP09/02_Playlist/Main.java new file mode 100644 index 0000000..273c10c --- /dev/null +++ b/DEV2.1/TP09/02_Playlist/Main.java @@ -0,0 +1,6 @@ +public class Main { + public static void main(String[] args) { + Fenetre fenetre = new Fenetre(); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/controle_machine_1/Acharnement.class b/DEV2.1/controle_machine_1/Acharnement.class new file mode 100644 index 0000000..585c36e Binary files /dev/null and b/DEV2.1/controle_machine_1/Acharnement.class differ diff --git a/DEV2.1/controle_machine_1/Acharnement.java b/DEV2.1/controle_machine_1/Acharnement.java new file mode 100644 index 0000000..f75fcbe --- /dev/null +++ b/DEV2.1/controle_machine_1/Acharnement.java @@ -0,0 +1,21 @@ +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++; + } + } +} \ No newline at end of file diff --git a/DEV2.1/controle_machine_1/AcharnementMain.class b/DEV2.1/controle_machine_1/AcharnementMain.class new file mode 100644 index 0000000..4003649 Binary files /dev/null and b/DEV2.1/controle_machine_1/AcharnementMain.class differ diff --git a/DEV2.1/controle_machine_1/AcharnementMain.java b/DEV2.1/controle_machine_1/AcharnementMain.java new file mode 100644 index 0000000..9eb63b3 --- /dev/null +++ b/DEV2.1/controle_machine_1/AcharnementMain.java @@ -0,0 +1,13 @@ +import java.awt.*; +import javax.swing.*; + +public class AcharnementMain { + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + fenetre.setSize(300, 200); + fenetre.setLocation(100, 100); + fenetre.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + fenetre.addWindowListener(new Acharnement()); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/controle_machine_1/Configuration.class b/DEV2.1/controle_machine_1/Configuration.class new file mode 100644 index 0000000..bc12362 Binary files /dev/null and b/DEV2.1/controle_machine_1/Configuration.class differ diff --git a/DEV2.1/controle_machine_1/Configuration.java b/DEV2.1/controle_machine_1/Configuration.java new file mode 100644 index 0000000..8d0f707 --- /dev/null +++ b/DEV2.1/controle_machine_1/Configuration.java @@ -0,0 +1,44 @@ +import java.util.Arrays; + +public class Configuration { + + private char[][] grille; + + + public Configuration() { + this.grille = new char[3][3]; + for(char[] ligne : grille) { + Arrays.fill(ligne, ' '); + } + } + + + public boolean estLibre(int x, int y) { + return this.grille[x][y] == ' '; + } + + + public Configuration jouer(int joueur, int x, int y) { + Configuration nouvelleConfig = this; + if (joueur == 1) { + nouvelleConfig.grille[x][y] = 'X'; + return nouvelleConfig; + } + nouvelleConfig.grille[x][y] = 'O'; + return nouvelleConfig; + } + + // Pas demandé + public char[][] getGrille() { + return this.grille; + } + + // Pas demandé + public String toString() { + String resultat = ""; + for (char[] ligne : this.grille) { + resultat += Arrays.toString(ligne); + } + return resultat; + } +} \ No newline at end of file diff --git a/DEV2.1/controle_machine_1/ConfigurationTest.class b/DEV2.1/controle_machine_1/ConfigurationTest.class new file mode 100644 index 0000000..b05f7a3 Binary files /dev/null and b/DEV2.1/controle_machine_1/ConfigurationTest.class differ diff --git a/DEV2.1/controle_machine_1/ConfigurationTest.java b/DEV2.1/controle_machine_1/ConfigurationTest.java new file mode 100644 index 0000000..76ae0ac --- /dev/null +++ b/DEV2.1/controle_machine_1/ConfigurationTest.java @@ -0,0 +1,8 @@ +public class ConfigurationTest { + public static void main(String[] args) { + Configuration nouveau = new Configuration(); + System.out.println(nouveau.estLibre(0, 0)); // Affiche bien true car la grille est vide + nouveau.jouer(1, 0, 0); // On joue dans cette case + System.out.println(nouveau.estLibre(0, 0)); // Affiche bien false car on vient de placer un joueur dans cette case + } +} \ No newline at end of file diff --git a/DEV2.1/controle_machine_1/Declinaisons.class b/DEV2.1/controle_machine_1/Declinaisons.class new file mode 100644 index 0000000..01b16f6 Binary files /dev/null and b/DEV2.1/controle_machine_1/Declinaisons.class differ diff --git a/DEV2.1/controle_machine_1/Declinaisons.java b/DEV2.1/controle_machine_1/Declinaisons.java new file mode 100644 index 0000000..56cacbe --- /dev/null +++ b/DEV2.1/controle_machine_1/Declinaisons.java @@ -0,0 +1,28 @@ +import java.awt.*; +import javax.swing.*; + +public class Declinaisons extends JComponent { + + private Color couleurTriangle; + + public Declinaisons(Color couleurTriangle) { + super(); + this.couleurTriangle = couleurTriangle; + } + + @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(this.couleurTriangle); + System.out.println("Width : " + this.getWidth() + " Height : " + this.getHeight()); + int[] coord_x = {this.getWidth()/4, this.getWidth()/4*3, this.getWidth()/2}; + int[] coord_y = {this.getHeight()/2, this.getHeight()/3, this.getHeight()/5*4}; + secondPinceau.fillPolygon(coord_x, coord_y, 3); + } +} \ No newline at end of file diff --git a/DEV2.1/controle_machine_1/DeclinaisonsMain.class b/DEV2.1/controle_machine_1/DeclinaisonsMain.class new file mode 100644 index 0000000..d2f7af4 Binary files /dev/null and b/DEV2.1/controle_machine_1/DeclinaisonsMain.class differ diff --git a/DEV2.1/controle_machine_1/DeclinaisonsMain.java b/DEV2.1/controle_machine_1/DeclinaisonsMain.java new file mode 100644 index 0000000..11257ae --- /dev/null +++ b/DEV2.1/controle_machine_1/DeclinaisonsMain.java @@ -0,0 +1,22 @@ +import java.awt.*; +import javax.swing.*; + +public class DeclinaisonsMain { + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + fenetre.setSize(300, 300); + fenetre.setLocation(100, 100); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + fenetre.setLayout(new GridLayout(2, 2)); + JPanel[] panneaux = {new JPanel(), new JPanel(), new JPanel(), new JPanel()}; + Color[] couleursTriangles = {Color.MAGENTA, Color.YELLOW, Color.CYAN, Color.BLUE}; + Color[] couleursFonds = {Color.CYAN, Color.PINK, Color.MAGENTA, Color.YELLOW}; + for (int i = 0; i != 4; i++) { + panneaux[i].setBackground(couleursFonds[i]); + panneaux[i].setLayout(new BorderLayout()); + panneaux[i].add(new Declinaisons(couleursTriangles[i]), BorderLayout.CENTER); + fenetre.add(panneaux[i]); + } + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/controle_machine_1/Duplication.class b/DEV2.1/controle_machine_1/Duplication.class new file mode 100644 index 0000000..1cec8ca Binary files /dev/null and b/DEV2.1/controle_machine_1/Duplication.class differ diff --git a/DEV2.1/controle_machine_1/Duplication.java b/DEV2.1/controle_machine_1/Duplication.java new file mode 100644 index 0000000..40bd0d4 --- /dev/null +++ b/DEV2.1/controle_machine_1/Duplication.java @@ -0,0 +1,9 @@ +import java.util.Arrays; + +public class Duplication { + public static void main(String[] args) { + double[] tab = new double[10]; + Arrays.fill(tab, 5.8); + System.out.println(Arrays.toString(tab)); + } +} \ No newline at end of file diff --git a/DEV2.1/controle_machine_1/Sautoir.class b/DEV2.1/controle_machine_1/Sautoir.class new file mode 100644 index 0000000..4259a53 Binary files /dev/null and b/DEV2.1/controle_machine_1/Sautoir.class differ diff --git a/DEV2.1/controle_machine_1/Sautoir.java b/DEV2.1/controle_machine_1/Sautoir.java new file mode 100644 index 0000000..ae72164 --- /dev/null +++ b/DEV2.1/controle_machine_1/Sautoir.java @@ -0,0 +1,38 @@ +import java.awt.*; +import javax.swing.*; + +public class Sautoir extends JComponent { + + @Override + protected void paintComponent(Graphics pinceau) { + // obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard + Graphics secondPinceau = pinceau.create(); + // obligatoire : si le composant n'est pas censé être transparent + if (this.isOpaque()) { + // obligatoire : on repeint toute la surface avec la couleur de fond + secondPinceau.setColor(this.getBackground()); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + + int[] coord_x = {0, this.getWidth(), 0, this.getWidth()}; + int[] coord_y = {0, 0, this.getHeight(), this.getHeight()}; + Polygon p = new Polygon(coord_x, coord_y, 4); + secondPinceau.setColor(Color.CYAN); + secondPinceau.fillPolygon(p); + + } + + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + GridLayout layout = new GridLayout(5, 5); + // on configure la fenetre + fenetre.setSize(250, 250); + fenetre.setLocation(0, 0); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + fenetre.setLayout(layout); + for (int i = 0; i != 25; i++) { + fenetre.add(new Sautoir()); + } + fenetre.setVisible(true); + } +} \ No newline at end of file