Files
Projet_DEV/src/linea/MenuPrincipal.java

60 lines
2.0 KiB
Java
Raw Normal View History

2026-02-10 15:44:59 +01:00
package linea;
import java.awt.*;
import javax.swing.*;
2026-02-10 16:34:22 +01:00
public class MenuPrincipal extends JPanel {
2026-02-10 15:44:59 +01:00
private JButton btnPlay;
2026-02-10 16:34:22 +01:00
private JButton btnCampaign; // Nouveau bouton
2026-02-10 15:44:59 +01:00
private JButton btnSettings;
private JButton btnQuit;
public MenuPrincipal(Jeu jeu) {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setBackground(new Color(45, 45, 45)); // Gris foncé
// Titre
JLabel titre = new JLabel("LINEA");
titre.setForeground(Color.WHITE);
titre.setFont(new Font("SansSerif", Font.BOLD, 60));
titre.setAlignmentX(Component.CENTER_ALIGNMENT);
2026-02-10 16:34:22 +01:00
// Création des Boutons
2026-02-10 15:44:59 +01:00
btnPlay = creerBouton("PLAY");
2026-02-10 16:34:22 +01:00
btnCampaign = creerBouton("CAMPAGNES"); // Création
2026-02-10 15:44:59 +01:00
btnSettings = creerBouton("SETTINGS");
btnQuit = creerBouton("QUIT");
// Actions
btnPlay.addActionListener(e -> jeu.lancerPartie());
2026-02-10 16:34:22 +01:00
// Action pour aller vers le menu campagne
// (Assure-toi d'avoir cette méthode dans ta classe Jeu)
btnCampaign.addActionListener(e -> jeu.afficherMenuCampagne());
2026-02-10 15:44:59 +01:00
btnSettings.addActionListener(e -> JOptionPane.showMessageDialog(this, "Options bientôt disponibles !"));
btnQuit.addActionListener(e -> System.exit(0));
2026-02-10 16:34:22 +01:00
// Mise en page (espacement vertical)
2026-02-10 15:44:59 +01:00
add(Box.createVerticalGlue());
add(titre);
add(Box.createRigidArea(new Dimension(0, 50)));
add(btnPlay);
add(Box.createRigidArea(new Dimension(0, 15)));
2026-02-10 16:34:22 +01:00
add(btnCampaign); // Ajout à l'affichage
add(Box.createRigidArea(new Dimension(0, 15)));
2026-02-10 15:44:59 +01:00
add(btnSettings);
add(Box.createRigidArea(new Dimension(0, 15)));
add(btnQuit);
add(Box.createVerticalGlue());
}
private JButton creerBouton(String texte) {
JButton b = new JButton(texte);
b.setFont(new Font("SansSerif", Font.PLAIN, 20));
b.setAlignmentX(Component.CENTER_ALIGNMENT);
b.setMaximumSize(new Dimension(200, 50));
2026-02-10 16:34:22 +01:00
b.setFocusable(false);
2026-02-10 15:44:59 +01:00
return b;
}
2026-02-10 16:34:22 +01:00
}