-implementation menu

This commit is contained in:
2026-02-10 15:44:59 +01:00
parent f14501abd1
commit 27f8f60bed
4 changed files with 123 additions and 114 deletions

View File

@@ -0,0 +1,52 @@
package linea;
import java.awt.*;
import javax.swing.*;
public class MenuPrincipal extends JPanel{
private JButton btnPlay;
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);
// Boutons
btnPlay = creerBouton("PLAY");
btnSettings = creerBouton("SETTINGS");
btnQuit = creerBouton("QUIT");
// Actions
btnPlay.addActionListener(e -> jeu.lancerPartie());
btnSettings.addActionListener(e -> JOptionPane.showMessageDialog(this, "Options bientôt disponibles !"));
btnQuit.addActionListener(e -> System.exit(0));
// Mise en page (espacement)
add(Box.createVerticalGlue());
add(titre);
add(Box.createRigidArea(new Dimension(0, 50)));
add(btnPlay);
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); // Pour ne pas voler le focus du clavier plus tard
return b;
}
}