a
This commit is contained in:
34
APL2.1/TP6_Dessin/tp06/Sablier.java
Normal file
34
APL2.1/TP6_Dessin/tp06/Sablier.java
Normal file
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user