-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.java
57 lines (50 loc) · 1.86 KB
/
Menu.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.BorderFactory;
import java.awt.Font;
import java.awt.Color;
/**
* The menu of the application
*/
public class Menu extends JFrame {
private JButton playButton; // Button the player presses to start the game
private String ICONPATH = "images/checkersIcon.png"; // path to the icon of the app
private String LOGO = "images/menuLogo.png"; // path to the logo of the menu
/**
* Create a starting menu
*/
public Menu() {
// General settings of frame
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
ImageIcon image = new ImageIcon(ICONPATH);
this.setIconImage(image.getImage());
this.setLayout(null);
this.setTitle("Draughts");
this.setResizable(false);
this.getContentPane().setBackground(Color.red);
// Logo of app
JLabel label = new JLabel();
label.setBounds(105, 0, 1340, 312);
ImageIcon logo = new ImageIcon(LOGO);
label.setIcon(logo);
// Play button
this.playButton = new JButton("Play");
playButton.setBounds(700, 512, 150, 50);
playButton.setFont(new Font("Public Pixel", Font.PLAIN, 20));
playButton.setBackground(new Color(0xD62E21));
playButton.setForeground(Color.black);
playButton.setBorder(BorderFactory.createEtchedBorder());
playButton.addActionListener(e -> {
this.dispose();
new GameRunner(new GameLogic(new CheckersBoard()));
});
playButton.setFocusable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.add(label);
this.add(playButton);
System.out.println(this.getSize());
}
}