From 7da3f456253eb1179b666da6373903a4d52d75c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ha=C3=AFssous?= Date: Tue, 26 Apr 2022 12:53:34 +0200 Subject: [PATCH] pause midi --- FrameJeu.java | 20 ++++++++------------ FrameMenu.java | 13 +++++-------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/FrameJeu.java b/FrameJeu.java index a5fb49b..e4654b6 100644 --- a/FrameJeu.java +++ b/FrameJeu.java @@ -9,12 +9,11 @@ public class FrameJeu{ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int frameWidth = screenSize.width * 2/3; int frameHeight = screenSize.height * 2/3; - int frameLocation[]={screenSize.width * 1/6, screenSize.height * 1/6}; - // On crée ensuite notre fenêtre + // On crée ensuite notre fenêtre avec des valeurs par défaut JFrame fenetre = new JFrame("Démineur - En Jeu"); fenetre.setSize(frameWidth,frameHeight); - fenetre.setLocation(frameLocation[0],frameLocation[1]); + fenetre.setLocation(screenSize.width * 1/6, screenSize.height * 1/6); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -25,7 +24,6 @@ public class FrameJeu{ Dimension caseSize = new Dimension(frameWidth/colonnes,frameWidth/colonnes); GridLayout damier = new GridLayout(lignes,colonnes); fenetre.setLayout(damier); - System.out.println(" Jeu " + damierSize.width +" "+ damierSize.height + " "+caseSize.width +" "+ caseSize.height ); // Création des couleurs Color gray1 = new Color(80,80,80); @@ -37,27 +35,24 @@ public class FrameJeu{ if (currentLine%2==0){ if (currentCase%2==0){ JPanel dark = new JPanel(); - dark.setPreferredSize(caseSize); + dark.setSize(caseSize); dark.setBackground(gray2); - if ((currentLine==0)&&(currentCase==8)){ - System.out.println("ok"); - } fenetre.add(dark); } else { JPanel light = new JPanel(); - light.setPreferredSize(caseSize); + light.setSize(caseSize); light.setBackground(gray1); fenetre.add(light); } } else { if (currentCase%2==0){ JPanel light = new JPanel(); - light.setPreferredSize(caseSize); + light.setSize(caseSize); light.setBackground(gray1); fenetre.add(light); } else { JPanel dark = new JPanel(); - dark.setPreferredSize(caseSize); + dark.setSize(caseSize); dark.setBackground(gray2); fenetre.add(dark); } @@ -65,7 +60,8 @@ public class FrameJeu{ } } fenetre.pack(); - System.out.println(" Jeu " + fenetre.getSize() + " "+caseSize.width +" "+ caseSize.height ); + fenetre.setLocation(damierSize.width * 1/6,(screenSize.height/2)- frameHeight/2); fenetre.setVisible(true); + System.out.println(" Jeu " + damierSize.width * 1/6 +" "+ ((screenSize.height/2)- frameHeight/2) + " "+caseSize.width +" "+ caseSize.height ); } } \ No newline at end of file diff --git a/FrameMenu.java b/FrameMenu.java index c9af1ff..6e91347 100644 --- a/FrameMenu.java +++ b/FrameMenu.java @@ -22,25 +22,22 @@ public class FrameMenu{ // Découpage de la fenêtre pour la mise en place du damier Dimension damierSize = fenetre.getSize(); - Dimension caseSize = new Dimension(damierSize.width/75, damierSize.height/75); - GridLayout damier = new GridLayout(caseSize.height, caseSize.width); + Dimension gridSize = new Dimension(damierSize.width/75, damierSize.height/75); + GridLayout damier = new GridLayout(gridSize.height, gridSize.width); fenetre.setLayout(damier); - System.out.println(" Menu " + damierSize.width +" "+ damierSize.height + " "+caseSize.width +" "+ caseSize.height ); + System.out.println(" Menu " + damierSize.width +" "+ damierSize.height + " "+gridSize.width +" "+ gridSize.height ); // Création des couleurs Color gray1 = new Color(80,80,80); Color gray2 = new Color(70,70,70); // Réalisation du damier et ajout d'éléments graphiques - for (int line=0; line