forked from menault/TD3_DEV51_Qualite_Algo
34 lines
1.0 KiB
Java
34 lines
1.0 KiB
Java
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);
|
|
|
|
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);
|
|
}
|
|
}
|