Erwan Gay

This commit is contained in:
Vieira
2022-02-14 11:02:04 +01:00
parent bd7322937f
commit 70c2cf6f54
8 changed files with 111 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,16 @@
import javax.swing.*;
import java.awt.*;
public class Formes {
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(500, 500);
fenetre.setLocation(100, 100);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
dessiner draw = new dessiner();
fenetre.add(draw, BorderLayout.CENTER);
fenetre.setVisible(true);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

View File

@@ -0,0 +1,32 @@
import javax.swing.*;
import java.awt.*;
public class dessiner extends JComponent {
private Image image;
public dessiner() {
super();
this.image = Toolkit.getDefaultToolkit().getImage("cercles.png");
}
@Override
protected void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
if (this.isOpaque()) {
// on change couleur de fond
secondPinceau.setColor(this.getBackground());
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
// rectangle zebi
secondPinceau.setColor(Color.BLUE);
secondPinceau.drawRect(5, 5, 55, 55);
// Bleu
secondPinceau.setColor(Color.GREEN);
secondPinceau.fillOval(75, 5, 50, 50);
// Vert
secondPinceau.setColor(new Color(150, 131, 236));
Font fonte = new Font("Gras", Font.BOLD, 24);
secondPinceau.setFont(fonte);
secondPinceau.drawString(">o<", 130, 30);
secondPinceau.drawImage(this.image, 200, 10, this);
}
}