BUT2/DEV/DEV2.1/test/Redimensioneur.java

27 lines
871 B
Java
Raw Permalink Normal View History

2023-10-23 13:23:36 +02:00
import javax.swing.JComponent;
import java.awt.*;
public class Redimensioneur extends JComponent {
Image[] listeElement;
public Redimensioneur(String[] listeImage){
this.listeElement = new Image[listeImage.length];
for (int i=0; i<listeImage.length; i++){
this.listeElement[i] = Toolkit.getDefaultToolkit().getImage(listeImage[i]);
}
}
@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());
}*/
secondPinceau.setColor(Color.RED);
secondPinceau.fillRect(0,0,60,60);
for (Image element: listeElement){
secondPinceau.drawImage(element,0, 0, this.getWidth(), this.getHeight(), this);
}
}
}