BUT2/DEV/DEV2.1/TP06_Dessin/Q1_Formes/Dessin.java~

23 lines
648 B
Java
Raw Normal View History

2023-10-23 13:23:36 +02:00
import javax.swing.JComponent;
import java.awt.Graphics;
public class Bonjour extends JComponent {
@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(new Color.BLUE);
secondPinceau.drawRect(20,20, 50, 50);
secondPinceau.setColor(new Color.GREEN);
secondPinceau.fillOval(80, 20, 50, 50);
secondPinceau.setColor(new Color.BLACK);
secondPinceau.drawString(140, 20, 50, 50)
}
}