import javax.swing.JComponent; import java.awt.*; public class Accueil extends JComponent { private Image fond; public Accueil() { super(); this.fond = Toolkit.getDefaultToolkit().getImage("login.jpg"); } @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.fond, 0, 0, this); } }