-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartMenu.java
More file actions
96 lines (72 loc) · 2.49 KB
/
Copy pathStartMenu.java
File metadata and controls
96 lines (72 loc) · 2.49 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
import java.awt.GridLayout;
import java.awt.Container;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JButton;
public class StartMenu extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 1L; // this was imported via Eclipse IDE, not sure what this means but I'll look it up
private JButton startGameBtn;
private JButton settingsBtn;
private JButton readMeBtn;
private GridLayout layout;
@SuppressWarnings("unused") // this was imported via Eclipse IDE, not sure what this means but I'll look it up
private Container container;
public StartMenu()
{
super("Project SLO | By: Joseph Bourne");
layout = new GridLayout(3, 1, 5, 5);
container = getContentPane();
setLayout(layout);
// I create three buttons and I set color for the text of the button
// and i set background color for the buttons also
startGameBtn = new JButton("Start Game");
startGameBtn.setBackground(new Color(80,40,18));
startGameBtn.setForeground(Color.WHITE);
add(startGameBtn);
settingsBtn = new JButton("Settings");
settingsBtn.setBackground(new Color(64,70,22));
settingsBtn.setForeground(Color.WHITE);
add(settingsBtn);
readMeBtn = new JButton("Game Rules: HOW TO PLAY");
readMeBtn.setBackground(new Color(87,82,126));
readMeBtn.setForeground(Color.WHITE);
add(readMeBtn);
setSize(450, 300);
setVisible(true);
// Creating inner class for button event handling
ButtonLink handler = new ButtonLink();
startGameBtn.addActionListener(handler);
settingsBtn.addActionListener(handler);
readMeBtn.addActionListener(handler);
}
private class ButtonLink implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
if(event.getSource() == readMeBtn) // if user clicks this button they create
{ // an object of GameRules class
GameRules rules = new GameRules();
rules.setSize(700,700);
rules.setVisible(true);
}
else if(event.getSource() == settingsBtn) // if user clicks this button they create
{ // an object of Settings class
Settings gameSettings = new Settings();
gameSettings.setSize(500,230);
gameSettings.setVisible(true);
}
else if(event.getSource() == startGameBtn) // if user clicks this button they create
{ // an object of StartGame class
StartGame newGame = new StartGame();
newGame.setSize(555,350);
newGame.setVisible(true);
}
}
}
}