feat: init VueGrille
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
*/
|
||||
package org;
|
||||
|
||||
import org.Models.Grille;
|
||||
import org.Views.VueGrille;
|
||||
|
||||
public class App {
|
||||
public String getGreeting() {
|
||||
return "Hello World!";
|
||||
@@ -10,5 +13,7 @@ public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(new App().getGreeting());
|
||||
Grille grille = new Grille(10, 10);
|
||||
VueGrille vueGrille = new VueGrille(grille);
|
||||
}
|
||||
}
|
||||
}
|
||||
21
app/src/main/java/org/Models/Grille.java
Normal file
21
app/src/main/java/org/Models/Grille.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package org.Models;
|
||||
|
||||
public class Grille {
|
||||
private boolean[][] grille;
|
||||
public int nbLignes;
|
||||
public int nbColonnes;
|
||||
|
||||
public Grille(int nbLignes, int nbColonnes) {
|
||||
this.nbLignes = nbLignes;
|
||||
this.nbColonnes = nbColonnes;
|
||||
this.grille = new boolean[nbLignes][nbColonnes];
|
||||
}
|
||||
|
||||
public int getNbLignes() {
|
||||
return nbLignes;
|
||||
}
|
||||
|
||||
public int getNbColonnes() {
|
||||
return nbColonnes;
|
||||
}
|
||||
}
|
||||
5
app/src/main/java/org/Models/Jeu.java
Normal file
5
app/src/main/java/org/Models/Jeu.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package org.Models;
|
||||
|
||||
public class Jeu {
|
||||
|
||||
}
|
||||
5
app/src/main/java/org/Models/PieceCourante.java
Normal file
5
app/src/main/java/org/Models/PieceCourante.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package org.Models;
|
||||
|
||||
public class PieceCourante {
|
||||
|
||||
}
|
||||
5
app/src/main/java/org/Models/PieceL.java
Normal file
5
app/src/main/java/org/Models/PieceL.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package org.Models;
|
||||
|
||||
public class PieceL {
|
||||
|
||||
}
|
||||
41
app/src/main/java/org/Views/VueGrille.java
Normal file
41
app/src/main/java/org/Views/VueGrille.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package org.Views;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.Border;
|
||||
|
||||
import org.Models.Grille;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.GridLayout;
|
||||
|
||||
public class VueGrille extends JFrame {
|
||||
private JPanel grillePanel;
|
||||
private int tailleJPanel = 1000;
|
||||
private Grille grille;
|
||||
|
||||
public VueGrille(Grille grille) {
|
||||
this.grille = grille;
|
||||
grillePanel = new JPanel(new GridLayout(grille.getNbLignes(), grille.getNbColonnes()));
|
||||
setSize(tailleJPanel, tailleJPanel);
|
||||
setContentPane(grillePanel);
|
||||
initialiserVueGrille();
|
||||
}
|
||||
|
||||
private void initialiserVueGrille() {
|
||||
Border border = BorderFactory.createLineBorder(Color.BLACK);
|
||||
for (int i = 0; i < grille.getNbLignes(); i++) {
|
||||
for (int j = 0; j < grille.getNbColonnes(); j++) {
|
||||
JPanel caseG = new JPanel();
|
||||
caseG.setBorder(border);
|
||||
caseG.setBackground(Color.WHITE);
|
||||
grillePanel.add(caseG);
|
||||
}
|
||||
}
|
||||
setVisible(true);
|
||||
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setTitle("TETRIS");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user