2023-03-20 17:57:20 +01:00
|
|
|
import javax.swing.*;
|
|
|
|
import java.awt.*;
|
|
|
|
|
|
|
|
public class Sautoir extends JComponent{
|
|
|
|
|
|
|
|
protected void paintComponent(Graphics pinceau) {
|
2023-03-27 11:28:45 +02:00
|
|
|
// obligatoire : on cree un nouveau pinceau pour pouvoir le modifier plus tard
|
|
|
|
Graphics pinceau2 = pinceau.create();
|
|
|
|
if (this.isOpaque()) {
|
|
|
|
// obligatoire : on repeint toute la surface avec la couleur de fond
|
|
|
|
pinceau2.setColor(this.getBackground());
|
|
|
|
pinceau2.fillRect(0, 0, this.getWidth(), this.getHeight());
|
|
|
|
}
|
|
|
|
pinceau2.setColor(Color.CYAN);
|
|
|
|
int[] x={0, getWidth()/2, getWidth()};
|
|
|
|
int[] yt={0, getHeight()/2, 0};
|
|
|
|
pinceau2.fillPolygon(x,yt,3);
|
|
|
|
int[] yb={ getHeight(), getHeight()/2, getHeight()};
|
|
|
|
pinceau2.fillPolygon(x,yb,3);
|
|
|
|
}
|
|
|
|
}
|