53 lines
1.7 KiB
Java
53 lines
1.7 KiB
Java
|
|
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;
|
||
|
|
}
|
||
|
|
}
|