Fin du TP06

This commit is contained in:
Simoes Lukas
2025-02-16 23:19:06 +01:00
parent dd8ce34656
commit 080e0022b8
10 changed files with 123 additions and 17 deletions

View File

@@ -3,13 +3,6 @@ import java.awt.*;
public class Formes extends JComponent {
private String typeComposant;
public Formes(String typeComposant) {
super();
this.typeComposant = typeComposant;
}
@Override
protected void paintComponent(Graphics pinceau) {
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
@@ -21,22 +14,30 @@ public class Formes extends JComponent {
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
if (this.typeComposant == "Carre") {
secondPinceau.setColor(new Color(51,153,255));
secondPinceau.fillRect(0, 0, 50, 50);
secondPinceau.setColor(Color.BLUE);
secondPinceau.drawRect(0,0,50,50);
}
// Carré
secondPinceau.setColor(new Color(51,153,255));
secondPinceau.fillRect(100, 100, 50, 50);
secondPinceau.setColor(Color.BLUE);
secondPinceau.drawRect(100,100,50,50);
if (this.typeComposant == "Disque") {
// TODO
}
// Disque
secondPinceau.setColor(Color.GREEN);
secondPinceau.drawOval(175,100,25,25);
// Texte
secondPinceau.setColor(new Color(80, 00, 80));
Font police = new Font("Arial", Font.BOLD, 24);
secondPinceau.setFont(police);
secondPinceau.drawString(">o<", 100, 200);
// Image
Image logo = Toolkit.getDefaultToolkit().getImage("logo.png");
secondPinceau.drawImage(logo, 175, 175, this);
}
public static void main(String[] args) {
JFrame fenetre = new JFrame();
Formes test = new Formes("Carre");
Formes test = new Formes();
// on configure la fenetre
fenetre.setSize(500, 500);
fenetre.setLocation(0, 0);