Affichage du jeu du pendu

This commit is contained in:
2025-10-08 11:15:14 +02:00
parent d074170b0f
commit 3bc6530305
6 changed files with 75 additions and 0 deletions

BIN
fr/iut/Projet/Action.class Normal file

Binary file not shown.

BIN
fr/iut/Projet/Display.class Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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();
}
}