56 lines
1.5 KiB
Java
56 lines
1.5 KiB
Java
/** La classe Couleur sert a dessiner les images en fonction
|
|
* des blocs
|
|
* @version 1.0
|
|
* @author Tanguy Domergue et Leni Boscher
|
|
*/
|
|
|
|
import java.awt.*;
|
|
import javax.swing.*;
|
|
import java.io.*;
|
|
import java.util.Random;
|
|
|
|
public class Couleur extends JPanel{
|
|
private int Couleur;
|
|
private Image img;
|
|
|
|
public Couleur(){
|
|
super();
|
|
}
|
|
|
|
@Override
|
|
protected void paintComponent(Graphics pinceau) {
|
|
Graphics secondPinceau = pinceau.create();
|
|
|
|
if (this.isOpaque()) {
|
|
|
|
secondPinceau.setColor(this.getBackground());
|
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
|
}
|
|
if (this.Couleur == 0){
|
|
secondPinceau.setColor(Color.WHITE);
|
|
secondPinceau.fillOval(0,0,50,50);
|
|
}
|
|
|
|
if (this.Couleur == 1){
|
|
Image img = Toolkit.getDefaultToolkit().getImage("./img/rouge.png");
|
|
secondPinceau.drawImage(img, 10, 10, this);
|
|
}
|
|
if (this.Couleur == 2){
|
|
Image img = Toolkit.getDefaultToolkit().getImage("./img/vert.png");
|
|
secondPinceau.drawImage(img, 10, 10, this);
|
|
}
|
|
if (this.Couleur == 3){
|
|
Image img = Toolkit.getDefaultToolkit().getImage("./img/bleu.png");
|
|
secondPinceau.drawImage(img, 10, 10, this);
|
|
}
|
|
}
|
|
|
|
public void setCouleur(int c) {
|
|
this.Couleur = c;
|
|
repaint();
|
|
}
|
|
|
|
public int getCouleur(){
|
|
return Couleur;
|
|
}
|
|
} |