import javax.swing.*; import java.awt.*; public class Couleur extends JComponent { protected void paintComponent(Graphics g) { Graphics secondPinceau = g.create(); secondPinceau.setColor(Color.getColor()); Polygon poly1 = new Polygon(); poly1.addPoint(0,0); poly1.addPoint(this.getWidth(), 0); poly1.addPoint(this.getWidth(), this.getHeight()); secondPinceau.fillPolygon(poly1); secondPinceau.setColor(Color.getColor()); Polygon poly2 = new Polygon(); poly2.addPoint(0, 0); poly2.addPoint(0, this.getHeight()); poly2.addPoint(this.getWidth(), this.getHeight()); secondPinceau.fillPolygon(poly2); } public String getColor(){ try { FileReader fr = new FileReader("rgb.txt"); StringReader sr = new StringReader(fr); try { sr.close(); } catch(IOException e) { System.out.println("Erreur de fermeture"); } } catch(IOException e) { System.out.println("Erreur d'ouverture"); } } public Couleur() { super(); } }