Developpement/23DEV1.1/TPS2/TP01/FluxDeCaracteres/FluxDeCaractere(suite)/Couleur.java

45 lines
1.1 KiB
Java
Raw Permalink Normal View History

2024-12-09 11:53:11 +01:00
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();
}
}