update
This commit is contained in:
BIN
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Q2Main.class
Normal file
BIN
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Q2Main.class
Normal file
Binary file not shown.
23
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Q2Main.java
Normal file
23
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Q2Main.java
Normal file
@@ -0,0 +1,23 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class Q2Main{
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame("Sautoir");
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setSize(288,215);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
GridLayout grille = new GridLayout(Sablier.nbLigne, Sablier.nbColone);
|
||||
fenetre.setLayout(grille);
|
||||
|
||||
Sablier[][] listeSablier = new Sablier[Sablier.nbLigne][Sablier.nbColone];
|
||||
for (int y=0; y<Sablier.nbLigne; y++){
|
||||
for (int x=0; x<Sablier.nbColone; x++){
|
||||
listeSablier[y][x] = new Sablier();
|
||||
fenetre.add(listeSablier[y][x]);
|
||||
}
|
||||
}
|
||||
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
13
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Q2Main.java~
Normal file
13
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Q2Main.java~
Normal file
@@ -0,0 +1,13 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class Q2Main{
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame("Sautoir");
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setSize(288,215);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
fenetre.setContentPane(contenus);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
BIN
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Sablier.class
Normal file
BIN
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Sablier.class
Normal file
Binary file not shown.
30
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Sablier.java
Normal file
30
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Sablier.java
Normal file
@@ -0,0 +1,30 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Sablier extends JComponent {
|
||||
public static int nbColone = 5;
|
||||
public static int nbLigne = 5;
|
||||
|
||||
public Sablier() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
int longueur = this.getWidth();
|
||||
int hauteur = this.getHeight();
|
||||
if (this.isOpaque()) {
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, longueur, hauteur);
|
||||
}
|
||||
int[] triangleXHaut = {0, longueur, longueur/2};
|
||||
int[] triangleYHaut = {0, 0, hauteur/2};
|
||||
int[] triangleXBas = {0, longueur, longueur/2};
|
||||
int[] triangleYBas = {hauteur, hauteur, hauteur/2};
|
||||
|
||||
secondPinceau.setColor(new Color(255,100,0));
|
||||
secondPinceau.fillPolygon(triangleXHaut, triangleYHaut, 3);
|
||||
secondPinceau.fillPolygon(triangleXBas, triangleYBas, 3);
|
||||
}
|
||||
}
|
||||
36
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Sablier.java~
Normal file
36
DEV/DEV2.1/TP06_Dessin/Q2_Sautoir/Sablier.java~
Normal file
@@ -0,0 +1,36 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class AfficheImage extends JComponent {
|
||||
public int numColone;
|
||||
public int numLigne;
|
||||
public static int nbColone = 5;
|
||||
public static int nbLigne = 5;
|
||||
|
||||
public AfficheImage(int numColone, int numLigne) {
|
||||
super();
|
||||
this.numColone = numColone;
|
||||
this.numLigne = numLigne;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
int longueur = this.getWidth();
|
||||
int hauteur = this.getHeight();
|
||||
if (this.isOpaque()) {
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, longueur, hauteur);
|
||||
}
|
||||
int uniteX = longueur/this.nbColone;
|
||||
int uniteY = hauteur/this.nbLigne;
|
||||
int[] triangleXHaut = {this.numColone*UniteX , (this.numColone+1)*UniteX , this.numColone*UniteX+UniteX/2};
|
||||
int[] triangleYHaut = {};
|
||||
int[] triangleXBas = {this.numColone*UniteX , (this.numColone+1)*UniteX , this.numColone*UniteX+UniteX/2};
|
||||
int[] triangleYBas = {};
|
||||
|
||||
secondPinceau.setColor(new Color(255,100,0));
|
||||
secondPinceau.fillPolygon(triangleXHaut, triangleYHaut, 3);
|
||||
secondPinceau.fillPolygon(triangleXBas, triangleYBas, 3);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user