34 lines
975 B
Java
34 lines
975 B
Java
import javax.swing.JComponent;
|
|
import java.awt.*;
|
|
|
|
public class Sablier extends JComponent
|
|
{
|
|
public Sablier()
|
|
{
|
|
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());
|
|
}
|
|
|
|
Polygon poly1 = new Polygon();
|
|
poly1.addPoint(0, 0);
|
|
poly1.addPoint(this.getWidth(), 0);
|
|
poly1.addPoint(this.getWidth()/2, this.getHeight()/2);
|
|
Polygon poly2 = new Polygon();
|
|
poly2.addPoint(0, this.getHeight());
|
|
poly2.addPoint(this.getWidth(), this.getHeight());
|
|
poly2.addPoint(this.getWidth()/2, this.getHeight()/2);
|
|
|
|
secondPinceau.setColor(Color.CYAN);
|
|
secondPinceau.fillPolygon(poly1);
|
|
secondPinceau.fillPolygon(poly2);
|
|
}
|
|
} |