Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 98ae6dc754 |
BIN
Affichage/Affiche.class
Normal file
BIN
Affichage/Affiche.class
Normal file
Binary file not shown.
55
Affichage/Affiche.java
Normal file
55
Affichage/Affiche.java
Normal file
@@ -0,0 +1,55 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
class Affiche extends JComponent {
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
||||
if (isOpaque()) {
|
||||
g.setColor(getBackground());
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
Graphics2D pinceau = (Graphics2D) g.create();
|
||||
|
||||
int pionTaille = 50;
|
||||
int pas = 70;
|
||||
int yBase = 60;
|
||||
int tabJeu[][] = {{0,0,1,2,0,0,0,0,0},
|
||||
{0,1,2,1,2,0,0,0,0},
|
||||
{0,2,1,2,1,2,1,0,0},
|
||||
{0,1,2,1,2,1,2,1,2},
|
||||
{1,2,1,2,0,2,1,2,1},
|
||||
{2,1,2,1,2,1,2,1,0},
|
||||
{0,0,1,2,1,2,1,2,0},
|
||||
{0,0,0,0,2,1,2,1,0},
|
||||
{0,0,0,0,0,2,1,0,0}};
|
||||
|
||||
for (int i = 0; i < pionsParLigne.length; i++) {
|
||||
int nbPions = pionsParLigne[i];
|
||||
int x = 60 + decalageLigne[i];
|
||||
int y = yBase + i * pas;
|
||||
|
||||
for (int j = 0; j < nbPions; j++) {
|
||||
if ((i+j) % 2 == 0)
|
||||
pinceau.setColor(Color.BLUE);
|
||||
else
|
||||
pinceau.setColor(Color.RED);
|
||||
|
||||
pinceau.fillOval(x + j * pas, y, pionTaille, pionTaille);
|
||||
}
|
||||
}
|
||||
|
||||
pinceau.dispose();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame("Forme diagonale miroir");
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.setSize(900, 800);
|
||||
fenetre.add(new Affiche());
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
BIN
Affichage/Test.class
Normal file
BIN
Affichage/Test.class
Normal file
Binary file not shown.
15
Affichage/Test.java
Normal file
15
Affichage/Test.java
Normal file
@@ -0,0 +1,15 @@
|
||||
import javax.swing.*;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(1500, 1050);
|
||||
fenetre.setLocation(150, 30);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
Affiche aff = new Affiche();
|
||||
fenetre.add(aff);
|
||||
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user