push
This commit is contained in:
BIN
DEV2.1/TP06/Exo2/Sablier.class
Normal file
BIN
DEV2.1/TP06/Exo2/Sablier.class
Normal file
Binary file not shown.
35
DEV2.1/TP06/Exo2/Sablier.java
Normal file
35
DEV2.1/TP06/Exo2/Sablier.java
Normal file
@@ -0,0 +1,35 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Sablier extends JComponent{
|
||||
private int[] xPoints;
|
||||
private int[] yPoints;
|
||||
private int[] yPoints2;
|
||||
public Sablier(){
|
||||
super();
|
||||
this.xPoints[0] = 0;
|
||||
this.xPoints[1] = this.getWidth()/2;
|
||||
this.xPoints[2] = this.getWidth();
|
||||
this.yPoints[0] = 0;
|
||||
this.yPoints[1] = this.getHeight()/2;
|
||||
this.yPoints[2] = 0;
|
||||
this.yPoints2[0] = this.getHeight();
|
||||
this.yPoints2[1] = this.getHeight()/2;
|
||||
this.yPoints2[2] = this.getHeight();
|
||||
}
|
||||
|
||||
@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.CYAN);
|
||||
secondPinceau.drawPolygon(xPoints, yPoints, 3);
|
||||
secondPinceau.fillPolygon(xPoints, yPoints, 3);
|
||||
secondPinceau.drawPolygon(xPoints, yPoints2, 3);
|
||||
secondPinceau.fillPolygon(xPoints, yPoints2, 3);
|
||||
}
|
||||
}
|
||||
|
||||
BIN
DEV2.1/TP06/Exo2/Sautoir.class
Normal file
BIN
DEV2.1/TP06/Exo2/Sautoir.class
Normal file
Binary file not shown.
17
DEV2.1/TP06/Exo2/Sautoir.java
Normal file
17
DEV2.1/TP06/Exo2/Sautoir.java
Normal file
@@ -0,0 +1,17 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Sautoir{
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(800, 800);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
GridLayout grille = new GridLayout(5,5);
|
||||
Sablier cadre = new Sablier();
|
||||
for (int i=0; i<24; i++){
|
||||
fenetre.add(cadre);
|
||||
}
|
||||
fenetre.setVisible(true);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user