import javax.swing.*; import java.awt.*; import java.awt.geom.*; import java.awt.event.*; public class Polyligne extends JFrame { private ProducteurDePoints producteurDePoints; public Polyligne(ProducteurDePoints producteurDePoints) { this.producteurDePoints = producteurDePoints; setTitle("Polyligne"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(300, 300); setLocationRelativeTo(null); JPanel panel = new JPanel() { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.BLACK); Point dernierPoint = null; Point pointActuel = producteurDePoints.suivant(); while (pointActuel != null) { if (dernierPoint != null) { g2d.draw(new Line2D.Double(dernierPoint, pointActuel)); } dernierPoint = pointActuel; pointActuel = producteurDePoints.suivant(); } } }; add(panel); setVisible(true); } public static void main(String[] args) { ProducteurDePoints producteur = new Etoile(); // Changez ici pour utiliser votre propre fournisseur new Polyligne(producteur); } }