Ajout menu principal
Classement logout et commencer
This commit is contained in:
@@ -6,10 +6,7 @@ public class LineaAppli {
|
||||
//-------------------------------------------------------------------------
|
||||
public static void main(String[] arg) {
|
||||
|
||||
Jeu jeu = new Jeu();
|
||||
|
||||
jeu.demarrer();
|
||||
|
||||
new MenuPrincipal();
|
||||
}
|
||||
|
||||
}
|
||||
98
src/MenuPrincipal.java
Normal file
98
src/MenuPrincipal.java
Normal file
@@ -0,0 +1,98 @@
|
||||
package linea;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class MenuPrincipal extends JFrame {
|
||||
|
||||
public MenuPrincipal() {
|
||||
// Configuration de la fenêtre du menu
|
||||
setTitle("LINEA - Menu Principal");
|
||||
setSize(400, 500);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setLocationRelativeTo(null); // Centre la fenêtre au milieu de l'écran
|
||||
setResizable(false);
|
||||
|
||||
// Panneau de fond (Même bleu que le jeu pour le style)
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(null); // On place les éléments manuellement
|
||||
panel.setBackground(new Color(0, 73, 220));
|
||||
setContentPane(panel);
|
||||
|
||||
// --- TITRE ---
|
||||
JLabel titre = new JLabel("LINEA", SwingConstants.CENTER);
|
||||
titre.setFont(new Font("Arial", Font.BOLD, 40));
|
||||
titre.setForeground(Color.WHITE);
|
||||
titre.setBounds(0, 50, 400, 60);
|
||||
panel.add(titre);
|
||||
|
||||
// --- BOUTON START ---
|
||||
JButton btnStart = new JButton("COMMENCER");
|
||||
btnStart.setBounds(100, 160, 200, 50);
|
||||
styleBouton(btnStart);
|
||||
btnStart.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
lancerJeu();
|
||||
}
|
||||
});
|
||||
panel.add(btnStart);
|
||||
|
||||
// --- BOUTON CLASSEMENT ---
|
||||
JButton btnClassement = new JButton("CLASSEMENT");
|
||||
btnClassement.setBounds(100, 230, 200, 50);
|
||||
styleBouton(btnClassement);
|
||||
btnClassement.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
afficherClassement();
|
||||
}
|
||||
});
|
||||
panel.add(btnClassement);
|
||||
|
||||
// --- BOUTON LOGOUT ---
|
||||
JButton btnLogout = new JButton("LOGOUT");
|
||||
btnLogout.setBounds(100, 300, 200, 50);
|
||||
styleBouton(btnLogout);
|
||||
btnLogout.setBackground(new Color(200, 50, 50)); // Rouge pour quitter
|
||||
btnLogout.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(0); // Ferme tout
|
||||
}
|
||||
});
|
||||
panel.add(btnLogout);
|
||||
|
||||
// Afficher la fenêtre
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
// Méthode pour lancer le jeu
|
||||
private void lancerJeu() {
|
||||
// On ferme le menu
|
||||
this.dispose();
|
||||
|
||||
// On lance le jeu existant
|
||||
Jeu jeu = new Jeu();
|
||||
jeu.demarrer();
|
||||
}
|
||||
|
||||
// Méthode pour afficher les classements
|
||||
private void afficherClassement() {
|
||||
// Comme on a retiré la BDD, on affiche une liste simulée
|
||||
String message = "TOP SCORES";
|
||||
|
||||
JOptionPane.showMessageDialog(this, message, "Classement", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
// Petite méthode pour rendre les boutons jolis
|
||||
private void styleBouton(JButton btn) {
|
||||
btn.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
btn.setBackground(Color.WHITE);
|
||||
btn.setForeground(Color.BLACK);
|
||||
btn.setFocusPainted(false);
|
||||
btn.setBorder(BorderFactory.createRaisedBevelBorder());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user