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

27 lines
900 B
Java

import javax.swing.*;
import java.awt.*;
public class Paintformes extends JComponent {
private Image image;
public Paintformes() {
super();
this.image = Toolkit.getDefaultToolkit().getImage("image.png");
}
@Override
protected 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(5, 5, 55, 55);
secondPinceau.setColor(Color.GREEN);
secondPinceau.fillOval(75, 5, 50, 50);
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);
}
}