feat: init VueGrille
This commit is contained in:
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