diff --git a/fr/iut/Projet/Action.class b/fr/iut/Projet/Action.class new file mode 100644 index 0000000..e967ee3 Binary files /dev/null and b/fr/iut/Projet/Action.class differ diff --git a/fr/iut/Projet/Display.class b/fr/iut/Projet/Display.class new file mode 100644 index 0000000..a2a308c Binary files /dev/null and b/fr/iut/Projet/Display.class differ diff --git a/fr/iut/Projet/PlayButtonListener.class b/fr/iut/Projet/PlayButtonListener.class new file mode 100644 index 0000000..b7e8595 Binary files /dev/null and b/fr/iut/Projet/PlayButtonListener.class differ diff --git a/src/fr/iut/Projet/Action.java b/src/fr/iut/Projet/Action.java new file mode 100644 index 0000000..365c5dd --- /dev/null +++ b/src/fr/iut/Projet/Action.java @@ -0,0 +1,20 @@ +package fr.iut.Projet; + +import javax.swing.*; +import java.awt.*; + +public class Action { + public Action() { + JFrame gameFrame = new JFrame("Jeu du pendu"); + gameFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + gameFrame.setSize(1040, 1000); + gameFrame.setLayout(new BorderLayout()); + + JLabel label = new JLabel("Bienvenue dans le jeu !"); + label.setFont(new Font("Arial", Font.BOLD, 28)); + label.setHorizontalAlignment(SwingConstants.CENTER); + + gameFrame.add(label, BorderLayout.CENTER); + gameFrame.setVisible(true); + } +} diff --git a/src/fr/iut/Projet/Display.java b/src/fr/iut/Projet/Display.java new file mode 100644 index 0000000..ec23f06 --- /dev/null +++ b/src/fr/iut/Projet/Display.java @@ -0,0 +1,35 @@ +package fr.iut.Projet; + +import javax.swing.*; +import java.awt.*; + +public class Display { + public static void main(String[] args) { + 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)); + + JLabel text = new JLabel("Hanging Man"); + text.setAlignmentX(Component.CENTER_ALIGNMENT); + text.setFont(new Font("Arial", Font.BOLD, 70)); + + 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 + play.addActionListener(new PlayButtonListener(frame)); + + frame.add(Box.createVerticalGlue()); + frame.add(text); + frame.add(Box.createVerticalStrut(30)); + frame.add(play); + frame.add(Box.createVerticalGlue()); + + frame.setVisible(true); + } +} + diff --git a/src/fr/iut/Projet/PlayButtonListener.java b/src/fr/iut/Projet/PlayButtonListener.java new file mode 100644 index 0000000..e8c32cd --- /dev/null +++ b/src/fr/iut/Projet/PlayButtonListener.java @@ -0,0 +1,20 @@ +package fr.iut.Projet; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class PlayButtonListener implements ActionListener { + + private JFrame parentFrame; + + public PlayButtonListener(JFrame frame) { + this.parentFrame = frame; + } + + @Override + public void actionPerformed(ActionEvent e) { + new Action(); // ouvre la fenêtre du jeu + parentFrame.dispose(); + } +}