diff --git a/fr/iut/Projet/Action.class b/fr/iut/Projet/Action.class index e967ee3..fe30c1f 100644 Binary files a/fr/iut/Projet/Action.class and b/fr/iut/Projet/Action.class differ diff --git a/fr/iut/Projet/Display.class b/fr/iut/Projet/Display.class index a2a308c..7e32efd 100644 Binary files a/fr/iut/Projet/Display.class and b/fr/iut/Projet/Display.class differ diff --git a/fr/iut/Projet/PlayButtonListener.class b/fr/iut/Projet/PlayButtonListener.class index b7e8595..1b41bc0 100644 Binary files a/fr/iut/Projet/PlayButtonListener.class and b/fr/iut/Projet/PlayButtonListener.class differ diff --git a/src/fr/iut/Projet/Action.java b/src/fr/iut/Projet/Action.java index 365c5dd..ee63c94 100644 --- a/src/fr/iut/Projet/Action.java +++ b/src/fr/iut/Projet/Action.java @@ -3,17 +3,28 @@ package fr.iut.Projet; import javax.swing.*; import java.awt.*; +/** + * Classe Action représentant la fenêtre principale du jeu "Hanging Man". + * Affiche un message de bienvenue. + */ public class Action { + + /** + * Constructeur. Crée et affiche la fenêtre du jeu avec un message. + */ public Action() { - JFrame gameFrame = new JFrame("Jeu du pendu"); + // Création de la fenêtre du jeu + JFrame gameFrame = new JFrame("Hanging Man"); gameFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gameFrame.setSize(1040, 1000); gameFrame.setLayout(new BorderLayout()); + // Label de bienvenue JLabel label = new JLabel("Bienvenue dans le jeu !"); label.setFont(new Font("Arial", Font.BOLD, 28)); label.setHorizontalAlignment(SwingConstants.CENTER); + // Ajouter le label et afficher la fenêtre gameFrame.add(label, BorderLayout.CENTER); gameFrame.setVisible(true); } diff --git a/src/fr/iut/Projet/Display.java b/src/fr/iut/Projet/Display.java index ec23f06..7cfb100 100644 --- a/src/fr/iut/Projet/Display.java +++ b/src/fr/iut/Projet/Display.java @@ -3,33 +3,46 @@ package fr.iut.Projet; import javax.swing.*; import java.awt.*; +/** + * Classe Display représentant le menu principal du jeu "Hanging Man". + * Elle affiche le titre et le bouton Play. + */ public class Display { + + /** + * Méthode principale. Crée et affiche la fenêtre du menu principal. + * @param args Arguments de la ligne de commande (non utilisés) + */ public static void main(String[] args) { + // Création de la fenêtre principale JFrame frame = new JFrame("Hanging Man"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(1040, 1000); frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS)); + // Titre du jeu JLabel text = new JLabel("Hanging Man"); text.setAlignmentX(Component.CENTER_ALIGNMENT); text.setFont(new Font("Arial", Font.BOLD, 70)); + // Bouton Play JButton play = new JButton("Play"); play.setAlignmentX(Component.CENTER_ALIGNMENT); play.setPreferredSize(new Dimension(300, 100)); play.setMaximumSize(new Dimension(300, 150)); play.setFont(new Font("Arial", Font.PLAIN, 36)); - // On utilise la classe séparée pour le listener + // Listener séparé pour gérer le clic sur Play play.addActionListener(new PlayButtonListener(frame)); + // Ajouter les composants avec de l'espace frame.add(Box.createVerticalGlue()); frame.add(text); frame.add(Box.createVerticalStrut(30)); frame.add(play); frame.add(Box.createVerticalGlue()); + // Affichage de la fenêtre frame.setVisible(true); } -} - +} \ No newline at end of file diff --git a/src/fr/iut/Projet/PlayButtonListener.java b/src/fr/iut/Projet/PlayButtonListener.java index e8c32cd..a0d34a1 100644 --- a/src/fr/iut/Projet/PlayButtonListener.java +++ b/src/fr/iut/Projet/PlayButtonListener.java @@ -4,17 +4,32 @@ import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +/** + * Classe PlayButtonListener qui gère le clic sur le bouton "Play" du menu. + * Lorsqu'on clique sur le bouton, cette classe ouvre la fenêtre du jeu + * et ferme la fenêtre principale. + */ public class PlayButtonListener implements ActionListener { + /** Référence à la fenêtre principale du menu */ private JFrame parentFrame; + /** + * Constructeur de PlayButtonListener. + * @param frame La fenêtre principale à fermer après ouverture du jeu + */ public PlayButtonListener(JFrame frame) { this.parentFrame = frame; } + /** + * Méthode appelée lorsque le bouton est cliqué. + * Ouvre la fenêtre du jeu et ferme la fenêtre principale. + * @param e L'événement déclenché par le clic + */ @Override public void actionPerformed(ActionEvent e) { - new Action(); // ouvre la fenêtre du jeu - parentFrame.dispose(); + new Action(); // Ouvre la fenêtre du jeu + parentFrame.dispose(); // Ferme la fenêtre principale } -} +} \ No newline at end of file