-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.java
More file actions
197 lines (170 loc) · 5.31 KB
/
MainMenu.java
File metadata and controls
197 lines (170 loc) · 5.31 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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Creates the main menu frame, which leads to the QQMenu, TrainMenu, AddMenu,
* RemoveMenu, and the StatsMenu.
*
* @author Austin Lei
* @version May 19, 2018
* @author Period: 2
* @author Assignment: QuickQuiz
*
* @author Sources: none
*/
public class MainMenu
{
/**
* Holds all of the GUI elements.
*/
private JFrame frame;
/**
* The ProblemDatabase to get all of the problems.
*/
private ProblemDatabase problem;
/**
* Holds all of the problem statistics for QuickQuiz.
*/
private Statistics stats;
/**
* Constructs the MainMenu Object, with five buttons that lead to all five
* functionalities.
*
* @param problem
* the ProblemDatabase that holds the problems
* @param statistics
* holds the statistics
*/
public MainMenu( ProblemDatabase problem, Statistics statistics )
{
this.problem = problem;
stats = statistics;
JButton QQMenu = new JButton( "Quick Quiz" );
QQMenu.setBounds( 200, 125, 400, 75 );
QQMenu.addActionListener( new QQButtonListener() );
JButton trainMenu = new JButton( "Training" );
trainMenu.setBounds( 200, 200, 400, 75 );
trainMenu.addActionListener( new TrainButtonListener() );
JButton addMenu = new JButton( "Add Problems" );
addMenu.setBounds( 200, 275, 400, 75 );
addMenu.addActionListener( new AddButtonListener() );
JButton removeMenu = new JButton( "Remove Problems" );
removeMenu.setBounds( 200, 350, 400, 75 );
removeMenu.addActionListener( new RemoveButtonListener() );
JButton statsMenu = new JButton( "Statistics" );
statsMenu.setBounds( 200, 425, 400, 75 );
statsMenu.addActionListener( new StatButtonListener() );
JLabel text = new JLabel( "Quick Quiz Generator" );
text.setFont( new Font( "font", Font.PLAIN, 48 ) );
text.setHorizontalAlignment( JLabel.CENTER );
text.setBounds( 100, 30, 600, 75 );
frame = new JFrame( "Main Menu" );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
Container c = frame.getContentPane();
frame.setLayout( null );
frame.setBounds( 0, 0, 800, 600 );
c.add( QQMenu );
c.add( trainMenu );
c.add( addMenu );
c.add( removeMenu );
c.add( statsMenu );
c.add( text );
frame.setResizable( false );
frame.setVisible( true );
}
/**
* Handles when the QQMenu button is clicked; when clicked, goes to QQMenu
* by closing all of MainMenu and creating a QQMenu object.
*
* @author Austin Lei
* @version May 19, 2018
* @author Period: 2
* @author Assignment: QuickQuiz
*
* @author Sources: none
*/
private class QQButtonListener implements ActionListener
{
public void actionPerformed( ActionEvent e )
{
TypeMenu typeMenu = new TypeMenu( problem, stats );
frame.dispose();
}
}
/**
* Handles when the TrainMenu button is clicked; when clicked, goes to
* TrainMenu by closing all of MainMenu and creating a QQMenu object.
*
* @author Austin Lei
* @version May 19, 2018
* @author Period: 2
* @author Assignment: QuickQuiz
*
* @author Sources: none
*/
private class TrainButtonListener implements ActionListener
{
public void actionPerformed( ActionEvent e )
{
TrainMenu trainMenu = new TrainMenu( problem, stats );
frame.dispose();
}
}
/**
* Handles when the AddMenu button is clicked; when clicked, goes to AddMenu
* by closing all of MainMenu and creating a QQMenu object.
*
* @author Austin Lei
* @version May 19, 2018
* @author Period: 2
* @author Assignment: QuickQuiz
*
* @author Sources: none
*/
private class AddButtonListener implements ActionListener
{
public void actionPerformed( ActionEvent e )
{
AddMenu addMenu = new AddMenu( problem, stats );
frame.dispose();
}
}
/**
* Handles when the RemoveMenu button is clicked; when clicked, goes to
* RemoveMenu by closing all of MainMenu and creating a QQMenu object.
*
* @author Austin Lei
* @version May 19, 2018
* @author Period: 2
* @author Assignment: QuickQuiz
*
* @author Sources: none
*/
private class RemoveButtonListener implements ActionListener
{
public void actionPerformed( ActionEvent e )
{
RemoveMenu removeMenu = new RemoveMenu( problem, stats );
frame.dispose();
}
}
/**
* Handles when the StatsMenu button is clicked; when clicked, goes to
* StatsMenu by closing all of MainMenu and creating a QQMenu object.
*
* @author Austin Lei
* @version May 19, 2018
* @author Period: 2
* @author Assignment: QuickQuiz
*
* @author Sources: none
*/
private class StatButtonListener implements ActionListener
{
public void actionPerformed( ActionEvent e )
{
StatsMenu statsMenu = new StatsMenu( problem, stats );
frame.dispose();
}
}
}