forked from menault/TD3_DEV51_Qualite_Algo
Affichage du jeu du pendu
This commit is contained in:
BIN
fr/iut/Projet/Action.class
Normal file
BIN
fr/iut/Projet/Action.class
Normal file
Binary file not shown.
BIN
fr/iut/Projet/Display.class
Normal file
BIN
fr/iut/Projet/Display.class
Normal file
Binary file not shown.
BIN
fr/iut/Projet/PlayButtonListener.class
Normal file
BIN
fr/iut/Projet/PlayButtonListener.class
Normal file
Binary file not shown.
20
src/fr/iut/Projet/Action.java
Normal file
20
src/fr/iut/Projet/Action.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/fr/iut/Projet/Display.java
Normal file
35
src/fr/iut/Projet/Display.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
20
src/fr/iut/Projet/PlayButtonListener.java
Normal file
20
src/fr/iut/Projet/PlayButtonListener.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user