-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartPage.java
More file actions
198 lines (163 loc) · 5.86 KB
/
Copy pathStartPage.java
File metadata and controls
198 lines (163 loc) · 5.86 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import java.lang.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
public class StartPage extends JFrame implements MouseListener, ActionListener
{
private JPanel panelMain;
private JButton btnStart,btnExit,btnHelp;
private JRadioButton l1,l2,l3;
private JLabel labelMain,labelSlevel,labelHS,lavelEasy,labelMid,labelHard;
private Font font1 = new Font("Consolas", Font.BOLD | Font.ITALIC, 35);
private Font font2 = new Font("Consolas", Font.BOLD | Font.ITALIC, 20);
private Color colorBG = new Color(36, 64, 109);
private Color bg = new Color(155, 242, 157);
MainPage MP;
int GameLavel;
int HSEasy,HSMid,HSHard;
int level,score;
String[] Value;
StartPage()
{
super("Puzzle Game");
this.setSize(1000,800);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panelMain = new JPanel();
panelMain.setBackground(colorBG);
panelMain.setLayout(null);
////////////////////////////////////// MAIN ////////////////////////////////////
labelMain = new JLabel();
labelMain.setFont(font1);
labelMain.setForeground(Color.WHITE);
labelMain.setBounds(350,50,500,80);
labelMain.setText("MATCH THE NUMBERS");
panelMain.setLayout(null);
panelMain.add(labelMain);
btnStart = new JButton("START");
btnStart.setBounds(450,160,100,40);
btnStart.setBackground(bg);
btnStart.addMouseListener(this);
btnStart.addActionListener(this);
panelMain.add(btnStart);
////////////////////////////////////// LEVEL SELECT ////////////////////////////
labelSlevel = new JLabel();
labelSlevel.setText("SELECT LEVEL");
labelSlevel.setBounds(450,230,160,40);
labelSlevel.setFont(font2);
labelSlevel.setForeground(Color.WHITE);
panelMain.add(labelSlevel);
l1 = new JRadioButton("EASY");
l1.setBounds(450,290,90,30);
l1.setForeground(Color.WHITE);
l1.setOpaque(false);
panelMain.add(l1);
l2 = new JRadioButton("MEDIUM");
l2.setBounds(450,330,90,30);
l2.setForeground(Color.WHITE);
l2.setOpaque(false);
panelMain.add(l2);
l3 = new JRadioButton("HARD");
l3.setBounds(450,370,90,30);
l3.setForeground(Color.WHITE);
l3.setOpaque(false);
panelMain.add(l3);
//////////////////////////////////// HIGHSCORES ////////////////////////////////
labelHS = new JLabel();
labelHS.setBounds(450,420,150,30);
labelHS.setText("HIGHSCORES");
labelHS.setFont(font2);
labelHS.setForeground(Color.WHITE);
panelMain.add(labelHS);
lavelEasy = new JLabel();
lavelEasy.setBounds(450,450,150,30);
lavelEasy.setText("EASY: "+HSEasy);
lavelEasy.setForeground(Color.WHITE);
panelMain.add(lavelEasy);
labelMid = new JLabel();
labelMid.setBounds(450,480,150,30);
labelMid.setText("MEDIUM: "+HSMid);
labelMid.setForeground(Color.WHITE);
panelMain.add(labelMid);
labelHard = new JLabel();
labelHard.setBounds(450,510,150,30);
labelHard.setText("HARD: "+HSHard);
labelHard.setForeground(Color.WHITE);
panelMain.add(labelHard);
////////////////////////////////////// END ////////////////////////////////////
btnExit = new JButton("EXIT");
btnExit.setBounds(450,560,80,20);
btnExit.setBackground(bg);
btnExit.addMouseListener(this);
btnExit.addActionListener(this);
panelMain.add(btnExit);
btnHelp = new JButton("HELP");
btnHelp.setBounds(570,560,80,20);
btnHelp.setBackground(bg);
btnHelp.addMouseListener(this);
btnHelp.addActionListener(this);
panelMain.add(btnHelp);
this.add(panelMain);
this.setVisible(true);
}//Constructor
//////////////////////////////////Mouse Event///////////////////////////////////
public void mousePressed(MouseEvent me)
{
}//mousePressed
public void mouseEntered(MouseEvent spme)
{
JButton button = (JButton)spme.getSource();
button.setBackground(Color.GREEN);
}//mouseEntered
public void mouseClicked(MouseEvent me)
{
}//mouseClicked
public void mouseExited(MouseEvent spme)
{
JButton button = (JButton)spme.getSource();
button.setBackground(bg);
}//mouseExited
public void mouseReleased(MouseEvent me)
{
}//mouseReleased
/////////////////////////////////// Action Performed///////////////////////////
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource().equals(btnStart))
{
if(l1.isSelected())
{
level=5;
score = 20;
MP = new MainPage(level,score);
this.setVisible(false);
}//Easy Selected
else if(l2.isSelected())
{
level=10;
score = 25;
MP = new MainPage(level,score);
this.setVisible(false);
}//Meidum Selected
else if(l3.isSelected())
{
level=15;
score = 30;
MP = new MainPage(level,score);
this.setVisible(false);
}//Hard Selected
else
{
JOptionPane.showMessageDialog(this,"PLEASE SELECT A LEVEL");
}//Nothing Selected
}//Start Pressed
else if(ae.getSource().equals(btnHelp))
{
JOptionPane.showMessageDialog(this,"Every pair of box holds The same Value.Click a box to Reveal it's Value, find the other one with the same Value.");
}//Start Pressed
else if(ae.getSource().equals(btnExit))
{
System.exit(0);
}//Start Pressed
}//actionPerformed
}//Class