APL/APL2.1/TP6/Formes/dessiner.java
2022-02-14 11:02:04 +01:00

32 lines
980 B
Java

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