import javax.swing.JComponent; import java.awt.*; public class Formes extends JComponent { private Image dessin; public Formes() { super(); this.dessin = Toolkit.getDefaultToolkit().getImage("cercles.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.drawImage(this.dessin, 10, 20, this); secondPinceau.setColor(Color.CYAN); secondPinceau.drawRect(5,100,50,50); secondPinceau.setColor(Color.GREEN); secondPinceau.fillOval(150,5,50,50); secondPinceau.setColor(new Color(173, 66, 245)); secondPinceau.setFont(new Font("TimesRoman", Font.PLAIN, 24)); secondPinceau.drawString(">0<", 150, 100); } }