import javax.swing.*; import java.awt.*; public class HangmanPanel extends JPanel { private int errors = 0; /*mettre à jour les erreurs*/ public void setErrors(int errors) { this.errors = errors; repaint(); } /*Dessiner le pendu*/ protected void paintComponent(Graphics g) { super.paintComponent(g); // Amélioration visuelle g.setColor(Color.BLACK); g.setFont(new Font("Arial", Font.BOLD, 12)); g.drawString("Erreurs: " + errors + "/9", 10, 20); g.drawLine(50, 300, 200, 300); g.drawLine(125, 300, 125, 50); g.drawLine(125, 50, 250, 50); g.drawLine(250, 50, 250, 80); if (errors > 0) g.drawOval(230, 80, 40, 40); if (errors > 1) g.drawLine(250, 120, 250, 200); if (errors > 2) g.drawLine(250, 140, 220, 170); if (errors > 3) g.drawLine(250, 140, 280, 170); if (errors > 4) g.drawLine(250, 200, 220, 250); if (errors > 5) g.drawLine(250, 200, 280, 250); if (errors > 6) g.drawLine(230, 90, 270, 90); if (errors > 7) g.drawString("X", 240, 100); if (errors > 8) g.drawString("X", 255, 100); } }