diff --git a/Banniere.java b/Banniere.java index 96d8be0..882cb0f 100644 --- a/Banniere.java +++ b/Banniere.java @@ -1,5 +1,6 @@ import javax.swing.*; import java.awt.*; +import java.awt.event.*; public class Banniere extends JPanel { private FrameJeu fenetre; @@ -25,24 +26,19 @@ public class Banniere extends JPanel { public void setVictoire(){ this.add(new Fin("Victoire !",this.getSize())); this.repaint(); - try { - Thread.sleep(5000); - } catch (InterruptedException e){ - System.out.println("oops you didn't see the end"); - } - new FrameMenu(); - this.fenetre.dispose(); + ActionListener backToMenu = new MenuListener(this.fenetre); + Timer timerMenu = new Timer(5000, backToMenu); + timerMenu.setRepeats(false); + timerMenu.start(); } // Méthode pour indiquer au joueur sa Défaite public void setDefaite(){ this.add(new Fin("Défaite !",this.getSize())); - this.repaint();try { - Thread.sleep(5000); - } catch (InterruptedException e){ - System.out.println("oops you didn't see the end"); - } - new FrameMenu(); - this.fenetre.dispose(); + this.repaint(); + ActionListener backToMenu = new MenuListener(this.fenetre); + Timer timerMenu = new Timer(5000, backToMenu); + timerMenu.setRepeats(false); + timerMenu.start(); } } \ No newline at end of file diff --git a/FrameMenu.java b/FrameMenu.java index bd6d914..bc61a6b 100644 --- a/FrameMenu.java +++ b/FrameMenu.java @@ -21,9 +21,9 @@ public class FrameMenu extends JFrame{ // On crée ensuite notre fenêtre this.setTitle("Démineur - Menu"); - Dimension frameSize = new Dimension (screenSize.width * 3/5,screenSize.height * 2/3); + Dimension frameSize = new Dimension (screenSize.width *2/5,screenSize.height * 2/3); this.setSize(frameSize); - this.setLocation(screenSize.width * 1/5, screenSize.height * 1/6); + this.setLocation(screenSize.width * 3/10, screenSize.height * 1/6); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(null); @@ -41,9 +41,9 @@ public class FrameMenu extends JFrame{ this.colonnes=sliderColonnes.getValue(); this.mines=sliderMines.getValue(); - sliderLignes.setBounds(frameSize.width*2/3, frameSize.height*6/15, frameSize.width/4, frameSize.height/20); - sliderColonnes.setBounds(frameSize.width*2/3, frameSize.height*8/15, frameSize.width/4, frameSize.height/20); - sliderMines.setBounds(frameSize.width*2/3, frameSize.height*10/15, frameSize.width/4, frameSize.height/20); + sliderLignes.setBounds(frameSize.width*3/5, frameSize.height*6/15, frameSize.width/3, frameSize.height/20); + sliderColonnes.setBounds(frameSize.width*3/5, frameSize.height*8/15, frameSize.width/3, frameSize.height/20); + sliderMines.setBounds(frameSize.width*3/5, frameSize.height*10/15, frameSize.width/3, frameSize.height/20); this.add(sliderLignes); this.add(sliderColonnes); @@ -53,9 +53,9 @@ public class FrameMenu extends JFrame{ this.showColumns= new JLabel("Colonnes : 25"); this.showMines= new JLabel("Mines : 50"); - this.showLines.setBounds(frameSize.width*2/3, frameSize.height*7/15, frameSize.width/4, frameSize.height/20); - this.showColumns.setBounds(frameSize.width*2/3, frameSize.height*9/15, frameSize.width/4, frameSize.height/20); - this.showMines.setBounds(frameSize.width*2/3, frameSize.height*11/15, frameSize.width/4, frameSize.height/20); + this.showLines.setBounds(frameSize.width*3/5, frameSize.height*5/15, frameSize.width/3, frameSize.height/20); + this.showColumns.setBounds(frameSize.width*3/5, frameSize.height*7/15, frameSize.width/3, frameSize.height/20); + this.showMines.setBounds(frameSize.width*3/5, frameSize.height*9/15, frameSize.width/3, frameSize.height/20); this.add(showLines); this.add(showColumns); @@ -64,7 +64,7 @@ public class FrameMenu extends JFrame{ JButton newGame = new JButton("New Game"); newGame.addActionListener(new NewGameListener(this)); - newGame.setBounds(frameSize.width*3/5, frameSize.height*12/15, frameSize.width/8, frameSize.height/15);; + newGame.setBounds(frameSize.width*3/5, frameSize.height*12/15, frameSize.width/5, frameSize.height/15);; this.add(newGame); JButton exit = new JButton("Quitter"); @@ -74,10 +74,11 @@ public class FrameMenu extends JFrame{ } }); - exit.setBounds(frameSize.width/10, frameSize.height*12/15, frameSize.width/8, frameSize.height/15); + exit.setBounds(frameSize.width/10, frameSize.height*12/15, frameSize.width/5, frameSize.height/15); this.add(exit); //TODO : Bouton charger + this.setResizable(false); this.setVisible(true); } diff --git a/Grille.java b/Grille.java index a1387ce..9f6fe52 100644 --- a/Grille.java +++ b/Grille.java @@ -187,7 +187,6 @@ public class Grille extends JPanel{ if (taille-mines==casesVisibles){ for (int i=0;i