bientôt une vraie mise en page

This commit is contained in:
Haïssous Kayyissa 2022-04-28 13:05:26 +02:00
parent fee7f5d7a2
commit abe49a58d0
2 changed files with 32 additions and 11 deletions

View File

@ -17,26 +17,47 @@ public class FrameJeu{
// En test
Color rose = new Color(236,0,140);
// Couleurs
//Color rose = new Color(236,0,140);
Color vert = new Color(0, 236, 96);
//Essai de mise en page car la bannière est par dessus la grille
fenetre.setLayout(new GridBagLayout());
GridBagConstraints miseEnPage = new GridBagConstraints();
// Création de la bannière (qui sera dans une autre classe)
Dimension grilleSize= grille.getGrilleSize();
JPanel banniere= new JPanel();
banniere.setBackground(vert);
Dimension banniereSize=new Dimension(grilleSize.width,grilleSize.height/10);
Dimension banniereSize=new Dimension(grilleSize.width,grilleSize.height/9);
banniere.setSize(banniereSize);
//banniere.setBounds( 0, 0, banniereSize.width, banniereSize.height);
JPanel plateau=grille.getGrille();
//plateau.setBounds( 0, banniereSize.height, grilleSize.width,grilleSize.height);
fenetre.add(banniere);
fenetre.add(plateau);
// mise en place de la bannière
miseEnPage.fill = GridBagConstraints.HORIZONTAL;
miseEnPage.gridx = 0;
miseEnPage.gridy = 0;
miseEnPage.weightx =banniereSize.width;
miseEnPage.ipady = banniereSize.height;
fenetre.add(banniere, miseEnPage);
// Mise en place de la grille
//miseEnPage.fill = GridBagConstraints.BOTH;
miseEnPage.anchor = GridBagConstraints.SOUTHEAST;
miseEnPage.gridx = 0;
miseEnPage.gridy = 1;
miseEnPage.weightx =grilleSize.width;
miseEnPage.ipady = grilleSize.height;
fenetre.add(grille.getGrille(), miseEnPage);
fenetre.pack();
fenetre.setSize(grilleSize.width,grilleSize.height*10/9);
Dimension fenetreSize=fenetre.getSize();
fenetre.setLocation(screenSize.width/2-(fenetreSize.width/2), screenSize.height/2-(fenetreSize.height/2));
//fenetre.setLayout(null);
//fenetre.setResizable(false);
fenetre.setVisible(true);
}
}

View File

@ -1,6 +1,6 @@
public class Test {
public static void main(String[] args) {
Grille grille=new Grille(20,25,15);
Grille grille=new Grille(4,8,15);
new FrameJeu(grille, 15);
}
}