package linea; import java.awt.*; import javax.swing.*; public class MenuPrincipal extends JPanel { private JButton btnPlay; private JButton btnCampaign; // Nouveau bouton 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); // Création des Boutons btnPlay = creerBouton("PLAY"); btnCampaign = creerBouton("CAMPAGNES"); // Création btnSettings = creerBouton("SETTINGS"); btnQuit = creerBouton("QUIT"); // Actions btnPlay.addActionListener(e -> jeu.lancerPartie()); // Action pour aller vers le menu campagne // (Assure-toi d'avoir cette méthode dans ta classe Jeu) btnCampaign.addActionListener(e -> jeu.afficherMenuCampagne()); btnSettings.addActionListener(e -> JOptionPane.showMessageDialog(this, "Options bientôt disponibles !")); btnQuit.addActionListener(e -> System.exit(0)); // Mise en page (espacement vertical) add(Box.createVerticalGlue()); add(titre); add(Box.createRigidArea(new Dimension(0, 50))); add(btnPlay); add(Box.createRigidArea(new Dimension(0, 15))); add(btnCampaign); // Ajout à l'affichage add(Box.createRigidArea(new Dimension(0, 15))); 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)); b.setFocusable(false); return b; } }