-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMainMenu.java
More file actions
99 lines (79 loc) · 3.67 KB
/
MainMenu.java
File metadata and controls
99 lines (79 loc) · 3.67 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import javax.management.StandardEmitterMBean;
import javax.swing.*;
import java.awt.*;
/** Represents the Main Menu of the game for the users.
* Users select the game mode that they want to play or select to get help for extra information.
* @author Nikolas Petrou
* @version 2.0
*/
public class MainMenu extends Screen
{
/** Creates a MainMenu, with the JButtons of the two game modes and a help JButton.
*/
MainMenu() {
super();
JPanel gameSelectionPanel = new JPanel();
JPanel gameInfoPanel = new JPanel();
gameSelectionPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(Gui.getMessages().getString("gameSelection")));
gameInfoPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(Gui.getMessages().getString("gameInfo")));
//Construct new Components
JLabel title = new JLabel("Memory Game");
JButton standardGameButton = new JButton("Standard");
JButton duelGameButton = new JButton("Duel");
JButton gameInfoButton = new JButton("Help");
//End
//Set properties of new Components
standardGameButton.setBackground(new Color(59, 89, 182));
standardGameButton.setForeground(Color.WHITE);
standardGameButton.setFocusPainted(false);
standardGameButton.setFont(new Font("Tahoma", Font.BOLD, 6));
duelGameButton.setBackground(new Color(59, 89, 182));
duelGameButton.setForeground(Color.WHITE);
duelGameButton.setFocusPainted(false);
duelGameButton.setFont(new Font("Tahoma", Font.BOLD, 6));
gameInfoButton.setBackground(new Color(59, 89, 182));
gameInfoButton.setForeground(Color.WHITE);
gameInfoButton.setFocusPainted(false);
gameInfoButton.setFont(new Font("Tahoma", Font.BOLD, 12));
//End
title.setText("<html><font color=black size=45><b>Memory Game</b></html>");
//Add Bounds
title.setBounds (575, 45, 500, 70);
standardGameButton.setBounds (385, 200, 255, 60);
standardGameButton.setPreferredSize(new Dimension(255, 60));
duelGameButton.setBounds (770, 200, 255, 60);
duelGameButton.setPreferredSize(new Dimension(255, 60));
gameInfoButton.setBounds(560, 900, 255, 60);
standardGameButton.setFont(getMainFont());
duelGameButton.setFont(getMainFont());
gameInfoButton.setFont(getMainFont());
gameInfoButton.setForeground(Color.WHITE);
gameInfoButton.setPreferredSize(new Dimension(255, 60));
gameInfoButton.addActionListener(e -> infoMessage());
standardGameButton.addActionListener(e -> {
getMainFrame().dispose();
Gui.setCurrentScreen(new StandardGameMenu());
});
duelGameButton.addActionListener(e -> {
getMainFrame().dispose();
Gui.setCurrentScreen(new DuelGameMenu());
});
GridLayout grid = new GridLayout(2, 0, 10, 20);
//Added Absolute Positioning
gameSelectionPanel.setLayout(null);
gameSelectionPanel.add(standardGameButton);
gameSelectionPanel.add(duelGameButton);
gameSelectionPanel.add(title);
gameInfoPanel.add(gameInfoButton);
getMainFrame().setLayout(grid);
getMainFrame().add(gameSelectionPanel);
getMainFrame().add(gameInfoPanel);
getMainFrame().setVisible(true);
}
/** Pops up a MessageDialog that provides the users with information about the game.
*/
private void infoMessage() {
JOptionPane.showMessageDialog(getMainFrame(), Gui.getMessages().getString("mainMenuInfo"),
Gui.getMessages().getString("help"), JOptionPane.INFORMATION_MESSAGE);
}
}