diff --git a/DEV2.1/TP09/03_Rectangle/GestionSouris.class b/DEV2.1/TP09/03_Rectangle/GestionSouris.class index 1725e18..9d72c95 100644 Binary files a/DEV2.1/TP09/03_Rectangle/GestionSouris.class and b/DEV2.1/TP09/03_Rectangle/GestionSouris.class differ diff --git a/DEV2.1/TP09/03_Rectangle/GestionSouris.java b/DEV2.1/TP09/03_Rectangle/GestionSouris.java index 96f1519..e7934f8 100644 --- a/DEV2.1/TP09/03_Rectangle/GestionSouris.java +++ b/DEV2.1/TP09/03_Rectangle/GestionSouris.java @@ -5,14 +5,16 @@ import java.awt.*; public class GestionSouris implements MouseListener { private Fenetre fenetre; - private Rectangle rect; + private JPanel rect; private int debutX; private int debutY; private int finX; private int finY; + private boolean rectActif; public GestionSouris(Fenetre fenetre) { this.fenetre = fenetre; + this.rectActif = false; } @@ -26,32 +28,28 @@ public class GestionSouris implements MouseListener { } public void mousePressed(MouseEvent evenement){ + if (this.rectActif) { + this.fenetre.remove(this.rect); + } System.out.println("Appui simple"); - this.fenetre.add(new Rectangle(evenement.getX(), evenement.getY(), evenement.getX()+200, evenement.getY()+200)); - this.debutX = evenement.getX(); - this.debutY = evenement.getY(); - this.rect = new Rectangle(this.debutX, this.debutY, evenement.getX(), evenement.getY()); - //this.fenetre.add(rect); + this.rect = new JPanel(); + this.rect.setOpaque(true); + this.rect.setBackground(Color.BLUE); + this.debutX = evenement.getX()-4; // Le -4 est du à un décalage de la méthode getX jsp pourquoi sah + this.debutY = evenement.getY()-26; // Pareil pour le -26 + this.fenetre.add(this.rect); this.fenetre.repaint(); } public void mouseReleased(MouseEvent evenement){ - this.finX = evenement.getX(); - this.finY = evenement.getY(); + this.rectActif = true; } - public int getDebutX() { - return this.debutX; - } - - public int getDebutY() { - return this.debutY; - } - public void setRect(int finX, int finY) { - this.rect.setBounds(this.debutX, this.debutY, finX, finY); - System.out.println("debut : [" + this.debutX + ", " + this.debutY + "]"); - System.out.println("fin : [" + finX + ", " + finY + "]"); + System.out.println(this.debutX + " " + this.debutY + " " + (finX-this.debutX+5) + " " + (finY-this.debutY-10) + ""); + this.rect.setBounds(this.debutX, this.debutY, finX-this.debutX-4, finY-this.debutY-26); // Décalage encore + //System.out.println("debut : [" + this.debutX + ", " + this.debutY + "]"); + //System.out.println("fin : [" + finX + ", " + finY + "]"); this.fenetre.repaint(); } } \ No newline at end of file diff --git a/DEV2.1/TP09/03_Rectangle/Rect.class b/DEV2.1/TP09/03_Rectangle/Rect.class new file mode 100644 index 0000000..b9f4cf8 Binary files /dev/null and b/DEV2.1/TP09/03_Rectangle/Rect.class differ diff --git a/DEV2.1/TP09/03_Rectangle/Rectangle.java b/DEV2.1/TP09/03_Rectangle/Rect.java similarity index 84% rename from DEV2.1/TP09/03_Rectangle/Rectangle.java rename to DEV2.1/TP09/03_Rectangle/Rect.java index a10f79c..d7fe324 100644 --- a/DEV2.1/TP09/03_Rectangle/Rectangle.java +++ b/DEV2.1/TP09/03_Rectangle/Rect.java @@ -1,14 +1,14 @@ import java.awt.*; import javax.swing.*; -public class Rectangle extends JComponent { +public class Rect extends JComponent { private int departX; private int departY; private int finX; private int finY; - public Rectangle(int departX, int departY, int finX, int finY) { + public Rect(int departX, int departY, int finX, int finY) { this.departX = departX; this.departY = departY; this.finX = finX; diff --git a/DEV2.1/TP09/04_Multiple/Fenetre.class b/DEV2.1/TP09/04_Multiple/Fenetre.class new file mode 100644 index 0000000..5d51810 Binary files /dev/null and b/DEV2.1/TP09/04_Multiple/Fenetre.class differ diff --git a/DEV2.1/TP09/04_Multiple/Fenetre.java b/DEV2.1/TP09/04_Multiple/Fenetre.java new file mode 100644 index 0000000..9c3ea1e --- /dev/null +++ b/DEV2.1/TP09/04_Multiple/Fenetre.java @@ -0,0 +1,58 @@ +import java.awt.*; +import javax.swing.*; + +public class Fenetre extends JFrame { + + private JLabel2 actif; + private boolean estActif; + + public Fenetre() { + this.estActif = false; + this.setLocation(100, 100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLayout(new GridLayout(14, 1)); + + JLabel2[] chromakopia = { + new JLabel2("St. Chroma"), + new JLabel2("Rah Tah Tah"), + new JLabel2("Noid"), + new JLabel2("Darling, I"), + new JLabel2("Hey Jane"), + new JLabel2("I Killed You"), + new JLabel2("Judge Judy"), + new JLabel2("Sticky"), + new JLabel2("Take Your Mask Off"), + new JLabel2("Tomorrow"), + new JLabel2("Thought I Was Dead"), + new JLabel2("Like Him"), + new JLabel2("Balloon"), + new JLabel2("I Hope You Find Your Way Home") + }; + + for (JLabel2 titre : chromakopia) { + GestionSouris gestion = new GestionSouris(titre, this); + titre.addMouseListener(gestion); + titre.setGestionnaireSouris(gestion); + this.add(titre); + } + + this.pack(); + } + + public boolean getEstActif() { + return this.estActif; + } + + public void setEstActif(boolean n) { + this.estActif = n; + } + + public void setActif(JLabel2 n) { + this.actif = n; + } + + public JLabel2 getActif() { + return this.actif; + } + +} \ No newline at end of file diff --git a/DEV2.1/TP09/04_Multiple/GestionSouris.class b/DEV2.1/TP09/04_Multiple/GestionSouris.class new file mode 100644 index 0000000..8b573c3 Binary files /dev/null and b/DEV2.1/TP09/04_Multiple/GestionSouris.class differ diff --git a/DEV2.1/TP09/04_Multiple/GestionSouris.java b/DEV2.1/TP09/04_Multiple/GestionSouris.java new file mode 100644 index 0000000..84c062b --- /dev/null +++ b/DEV2.1/TP09/04_Multiple/GestionSouris.java @@ -0,0 +1,67 @@ +import java.awt.event.*; +import javax.swing.*; +import java.awt.*; + +public class GestionSouris implements MouseListener { + + private JLabel2 titre; + private Fenetre fenetre; + private JLabel2 actif; + private boolean actuelEstActif; + + public GestionSouris(JLabel2 titre, Fenetre fenetre) { + this.titre = titre; + this.fenetre = fenetre; + } + + 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){ + if (!this.actuelEstActif) { + this.titre.setOpaque(true); + this.titre.setBackground(null); + this.titre.repaint(); + } + else { + this.titre.setBackground(Color.LIGHT_GRAY); + this.titre.repaint(); + } + } + + public void mousePressed(MouseEvent evenement){ + this.titre.setBackground(Color.LIGHT_GRAY); + this.actuelEstActif = true; + if (!evenement.isControlDown()) { + System.out.println("Ctrl not Pressed"); + } + else { + System.out.println("Ctrl Pressed"); + } + this.titre.repaint(); + + if (this.fenetre.getEstActif() && !evenement.isControlDown()) { + this.fenetre.getActif().setBackground(null); + this.fenetre.getActif().getGestionnaireSouris().setActuelEstActif(false); + this.fenetre.getActif().repaint(); + } + + if (!evenement.isControlDown()) { + this.fenetre.setEstActif(true); + this.fenetre.setActif(this.titre); + } + } + + public void mouseReleased(MouseEvent evenement){ + } + + public void setActuelEstActif(boolean n) { + this.actuelEstActif = n; + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/04_Multiple/JLabel2.class b/DEV2.1/TP09/04_Multiple/JLabel2.class new file mode 100644 index 0000000..f53a08a Binary files /dev/null and b/DEV2.1/TP09/04_Multiple/JLabel2.class differ diff --git a/DEV2.1/TP09/04_Multiple/JLabel2.java b/DEV2.1/TP09/04_Multiple/JLabel2.java new file mode 100644 index 0000000..fe47109 --- /dev/null +++ b/DEV2.1/TP09/04_Multiple/JLabel2.java @@ -0,0 +1,19 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.*; + +public class JLabel2 extends JLabel { + private GestionSouris gestionnaireSouris; + + public JLabel2(String s) { + super(s); + } + + public void setGestionnaireSouris(GestionSouris n) { + this.gestionnaireSouris = n; + } + + public GestionSouris getGestionnaireSouris() { + return this.gestionnaireSouris; + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/04_Multiple/Main.class b/DEV2.1/TP09/04_Multiple/Main.class new file mode 100644 index 0000000..4bfefb8 Binary files /dev/null and b/DEV2.1/TP09/04_Multiple/Main.class differ diff --git a/DEV2.1/TP09/04_Multiple/Main.java b/DEV2.1/TP09/04_Multiple/Main.java new file mode 100644 index 0000000..273c10c --- /dev/null +++ b/DEV2.1/TP09/04_Multiple/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/05_Balle/Balle.class b/DEV2.1/TP09/05_Balle/Balle.class new file mode 100644 index 0000000..5a0ae12 Binary files /dev/null and b/DEV2.1/TP09/05_Balle/Balle.class differ diff --git a/DEV2.1/TP09/05_Balle/Balle.java b/DEV2.1/TP09/05_Balle/Balle.java new file mode 100644 index 0000000..4f830e3 --- /dev/null +++ b/DEV2.1/TP09/05_Balle/Balle.java @@ -0,0 +1,45 @@ +import java.awt.*; +import javax.swing.*; + +public class Balle extends JComponent { + + private int posXImage; + private int posYImage; + private Graphics pinceau; + + public Balle(int posXImage, int posYImage) { + this.posXImage = posXImage; + this.posYImage = posYImage; + } + + 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.clearRect(0, 0, this.getWidth(), this.getHeight()); + + Image img = Toolkit.getDefaultToolkit().getImage("terre.jpg"); + secondPinceau.drawImage(img, 0, 0, this); + + Image balle = Toolkit.getDefaultToolkit().getImage("balle.png"); + secondPinceau.drawImage(balle, this.posXImage, this.posYImage, this); + + this.pinceau = secondPinceau; + } + + public void clearComponent() { + this.pinceau.clearRect(0, 0, this.getWidth(), this.getHeight()); + } + + public int getPosX() { + return this.posXImage; + } + + public int getPosY() { + return this.posYImage; + } +} diff --git a/DEV2.1/TP09/05_Balle/Fenetre.class b/DEV2.1/TP09/05_Balle/Fenetre.class new file mode 100644 index 0000000..4c84e4e Binary files /dev/null and b/DEV2.1/TP09/05_Balle/Fenetre.class differ diff --git a/DEV2.1/TP09/05_Balle/Fenetre.java b/DEV2.1/TP09/05_Balle/Fenetre.java new file mode 100644 index 0000000..0d8b54a --- /dev/null +++ b/DEV2.1/TP09/05_Balle/Fenetre.java @@ -0,0 +1,16 @@ +import java.awt.*; +import javax.swing.*; + +public class Fenetre extends JFrame { + public Fenetre() { + this.setLocation(100,100); + this.setSize(394,594); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLayout(new GridLayout(1, 1)); + Balle balle = new Balle(50, 50); + this.add(balle); + GestionSouris gestionSouris = new GestionSouris(); + this.addMouseListener(gestionSouris); + this.addMouseMotionListener(new GestionnaireMouvementImage(this, balle, balle.getPosX(), balle.getPosY(), gestionSouris)); + } +} diff --git a/DEV2.1/TP09/05_Balle/Fond.class b/DEV2.1/TP09/05_Balle/Fond.class new file mode 100644 index 0000000..e43a4ef Binary files /dev/null and b/DEV2.1/TP09/05_Balle/Fond.class differ diff --git a/DEV2.1/TP09/05_Balle/GestionSouris.class b/DEV2.1/TP09/05_Balle/GestionSouris.class new file mode 100644 index 0000000..73de484 Binary files /dev/null and b/DEV2.1/TP09/05_Balle/GestionSouris.class differ diff --git a/DEV2.1/TP09/05_Balle/GestionSouris.java b/DEV2.1/TP09/05_Balle/GestionSouris.java new file mode 100644 index 0000000..d44bae2 --- /dev/null +++ b/DEV2.1/TP09/05_Balle/GestionSouris.java @@ -0,0 +1,43 @@ +import java.awt.event.*; +import javax.swing.*; +import java.awt.*; + +public class GestionSouris implements MouseListener { + + private int sourisX; + private int sourisY; + + + public void mouseClicked(MouseEvent evenement) { + } + + public void mouseEntered(MouseEvent evenement){ + } + + public void mouseExited(MouseEvent evenement){ + } + + public void mousePressed(MouseEvent evenement){ + this.sourisX = evenement.getX()-4; + this.sourisY = evenement.getY()-26; + } + + public void mouseReleased(MouseEvent evenement){ + } + + public int getSourisX() { + return this.sourisX; + } + + public int getSourisY() { + return this.sourisY; + } + + public void setSourisX(int a) { + this.sourisX = a; + } + + public void setSourisY(int b) { + this.sourisY = b; + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/05_Balle/GestionnaireMouvementImage.class b/DEV2.1/TP09/05_Balle/GestionnaireMouvementImage.class new file mode 100644 index 0000000..4e2910a Binary files /dev/null and b/DEV2.1/TP09/05_Balle/GestionnaireMouvementImage.class differ diff --git a/DEV2.1/TP09/05_Balle/GestionnaireMouvementImage.java b/DEV2.1/TP09/05_Balle/GestionnaireMouvementImage.java new file mode 100644 index 0000000..7acb858 --- /dev/null +++ b/DEV2.1/TP09/05_Balle/GestionnaireMouvementImage.java @@ -0,0 +1,45 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.*; + +public class GestionnaireMouvementImage implements MouseMotionListener { + + private Fenetre fenetre; + private Balle balle; + private int posX; + private int posY; + private GestionSouris gestionSouris; + + public GestionnaireMouvementImage(Fenetre fenetre, Balle balle, int x, int y, GestionSouris gestionSouris) { + this.fenetre = fenetre; + this.balle = balle; + this.posX = x; + this.posY = y; + this.gestionSouris = gestionSouris; + } + + public void mouseDragged(MouseEvent evenement) { + if (evenement.getX()-4 >= this.posX && evenement.getX()-4 <= this.posX+29 && + evenement.getY()-26 >= this.posY && evenement.getY()-26 <= this.posY+28) { + System.out.println("I'm gonna fucking kill myself"); + this.fenetre.remove(balle); + int diffX = (evenement.getX()-4) - this.gestionSouris.getSourisX(); + int diffY = (evenement.getY()-26) - this.gestionSouris.getSourisY(); + this.posX += diffX; + this.posY += diffY; + + this.gestionSouris.setSourisX(evenement.getX()-4); + this.gestionSouris.setSourisY(evenement.getY()-26); + Balle balle = new Balle(this.posX, this.posY); + this.balle = balle; + this.fenetre.add(balle); + this.fenetre.revalidate(); + this.fenetre.repaint(); + } + } + + public void mouseMoved(MouseEvent evenement) { + + } +} + diff --git a/DEV2.1/TP09/05_Balle/Main.class b/DEV2.1/TP09/05_Balle/Main.class new file mode 100644 index 0000000..4bfefb8 Binary files /dev/null and b/DEV2.1/TP09/05_Balle/Main.class differ diff --git a/DEV2.1/TP09/05_Balle/Main.java b/DEV2.1/TP09/05_Balle/Main.java new file mode 100644 index 0000000..2768c3d --- /dev/null +++ b/DEV2.1/TP09/05_Balle/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/05_Balle/Rect.class b/DEV2.1/TP09/05_Balle/Rect.class new file mode 100644 index 0000000..b9f4cf8 Binary files /dev/null and b/DEV2.1/TP09/05_Balle/Rect.class differ diff --git a/DEV2.1/TP09/05_Balle/Rect.java b/DEV2.1/TP09/05_Balle/Rect.java new file mode 100644 index 0000000..d7fe324 --- /dev/null +++ b/DEV2.1/TP09/05_Balle/Rect.java @@ -0,0 +1,29 @@ +import java.awt.*; +import javax.swing.*; + +public class Rect extends JComponent { + + private int departX; + private int departY; + private int finX; + private int finY; + + public Rect(int departX, int departY, int finX, int finY) { + this.departX = departX; + this.departY = departY; + this.finX = finX; + this.finY = finY; + } + + @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.fillRect(this.departX, this.departY, this.finX-this.departX, this.finY-this.departY); + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/05_Balle/balle.png b/DEV2.1/TP09/05_Balle/balle.png new file mode 100644 index 0000000..ce05b08 Binary files /dev/null and b/DEV2.1/TP09/05_Balle/balle.png differ diff --git a/DEV2.1/TP09/05_Balle/terre.jpg b/DEV2.1/TP09/05_Balle/terre.jpg new file mode 100644 index 0000000..877e5bf Binary files /dev/null and b/DEV2.1/TP09/05_Balle/terre.jpg differ diff --git a/DEV2.1/TP10/04_Apparences/Fond$2.class b/DEV2.1/TP10/04_Apparences/Fond$2.class index 4c603fd..59864e2 100644 Binary files a/DEV2.1/TP10/04_Apparences/Fond$2.class and b/DEV2.1/TP10/04_Apparences/Fond$2.class differ diff --git a/DEV2.1/TP10/04_Apparences/Fond.class b/DEV2.1/TP10/04_Apparences/Fond.class index 7992d10..5b2f074 100644 Binary files a/DEV2.1/TP10/04_Apparences/Fond.class and b/DEV2.1/TP10/04_Apparences/Fond.class differ diff --git a/DEV2.1/TP10/04_Apparences/Fond.java b/DEV2.1/TP10/04_Apparences/Fond.java index 08e9ac0..dde67d1 100644 --- a/DEV2.1/TP10/04_Apparences/Fond.java +++ b/DEV2.1/TP10/04_Apparences/Fond.java @@ -38,13 +38,13 @@ public class Fond { bouton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evenement) { - panneau.setBackground(Color.MAGENTA); + panneau.setBackground(Color.RED); } }); bouton3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evenement) { - panneau.setBackground(Color.YELLOW); + panneau.setBackground(Color.MAGENTA); } });