import javax.swing.JComponent; import java.awt.*; public class Formes { private Image trucChelou; public void paintComponent(Graphics g) { Graphics secondPinceau = g.create(); if(isOpaque()) { secondPinceau.setColor(getBackground()); secondPinceau.drawRect(0, 0, getWidth(), getHeight()); } secondPinceau.setColor(color.BLUE); fillRect(10, 10, 50, 50); secondPinceau.setColor(color.GREEN); drawOval(30,30, 25, 25); secondPinceau.setColor(color.MAGENTA); secondPinceau.drawString(">o<",getWidth()/2 - 30, getHeight()/2); secondPinceau.("cercles.png", ); } public static void main(String[] args) { JFrame frame = new JFrame("Frame"); frame.setSize(400, 400); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }