BUT2/DEV/DEV2.1/test/Redimensioneur.java
2023-10-23 13:23:36 +02:00

27 lines
871 B
Java

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);
}
}
}