PT21_APL2020/Menu.java

74 lines
2.2 KiB
Java
Raw Normal View History

2021-12-06 22:07:53 +01:00
/**
* La classe <code>Menu</code> est utilisée pour créer le menu du jeu
*
* @version 0.1
* @author Adil HAMMERSCHMIDT & Lucas GRANDJEAN
*/
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.border.BevelBorder;
public class Menu extends JFrame {
private JButton playBtn;
private JButton playFromFileBtn;
private JButton quitBtn;
public Menu() {
JFrame frame = new JFrame("SameGame by Lucas Grandjean & Adil Hammerschmidt");
frame.setPreferredSize(new Dimension(300, 300));
frame.add(new MenuPanel());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public class MenuPanel extends JPanel {
public MenuPanel() {
MenuListener mListener = new MenuListener();
setOpaque(true);
setBackground(new Color(67,133,200));
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.NORTH;
add(new JLabel("<html><h1><strong><i>SameGame</i></strong></h1><hr></html>"), gbc);
add(new JLabel("<html>Lucas GRANDJEAN</html>"), gbc);
add(new JLabel("<html>Adil HAMMERSCHMIDT<hr></html>"), gbc);
gbc.anchor = GridBagConstraints.CENTER;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 5, 0);
JPanel buttons = new JPanel(new GridBagLayout());
buttons.setBackground(new Color(57,108,160));
buttons.setBorder(new BevelBorder(BevelBorder.RAISED));
playBtn = new JButton("Jouer");
playBtn.addActionListener(mListener);
playFromFileBtn = new JButton("Charger une grille");
playFromFileBtn.addActionListener(mListener);
quitBtn = new JButton("Quitter");
quitBtn.addActionListener(mListener);
buttons.add(playBtn, gbc);
buttons.add(playFromFileBtn, gbc);
buttons.add(quitBtn, gbc);
gbc.weighty = 1;
add(buttons, gbc);
}
}
}