-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReportWindow.java
More file actions
236 lines (179 loc) · 7.51 KB
/
Copy pathReportWindow.java
File metadata and controls
236 lines (179 loc) · 7.51 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
Made for Bellevue College RISE Makerspace by Evan Johnson
Project Description:
Digital sign-in system. New users input their first name, last name, student ID number,
and college email. When a user is in the system already, all they need to sign in is
their student ID number, greatly shortening sign-in time.
Class Description: Administrator report window. GUI window element used by the staff to
create new .csv files containing student information and get a quick preview of the number
of attendees.
*/
package src;
import javax.swing.*;
import java.awt.*;
public class ReportWindow
{
// fonts for various elements
private Font titleFont = new Font(Font.SANS_SERIF, 0, 24);
private Font labelFont = new Font(Font.SANS_SERIF, 0, 18);
private Font fieldFont = new Font(Font.SANS_SERIF, 0, 14);
private Font buttonFont = new Font(Font.SANS_SERIF, 0, 18);
private Font dateFont = new Font(Font.MONOSPACED, 0, 16);
JFrame frm;
private JPanel pnl;
private JLabel titleLabel;
// Date Panel
private JPanel datePanel;
JLabel startDateLabel;
JLabel endDateLabel;
JTextField startDateField;
JTextField endDateField;
// Report Panel
private JPanel reportPanel;
private JPanel statPanel;
private JPanel btnPanel;
// Stat Panel
private JPanel distinctPanel;
private JLabel distinctLabel;
JTextField distinctField;
private JPanel totalPanel;
private JLabel totalLabel;
JTextField totalField;
// Btn Panel
JButton reportDateBtn;
JButton reportAllBtn;
JButton closeBtn;
public ReportWindow()
{
frm = new JFrame("Attendance Report");
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension screenSize = tk.getScreenSize();
Dimension windowSize = new Dimension((int) (screenSize.width / 1.5), (int) (screenSize.height / 1.5));
// Setting up Main Panel
pnl = new JPanel();
pnl.setLayout(new BoxLayout(pnl, BoxLayout.PAGE_AXIS));
//Title Label
titleLabel = new JLabel("Attendance Report");
titleLabel.setAlignmentX((float) 0.5);
titleLabel.setFont(titleFont);
// DATE PANEL * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// start date label
startDateLabel = new JLabel("Start Date: ");
startDateLabel.setAlignmentX((float) 0.5);
startDateLabel.setFont(labelFont);
// start date field
startDateField = new JTextField();
startDateField.setAlignmentX((float) 0.5);
startDateField.setMaximumSize(new Dimension(300, 35));
startDateField.setPreferredSize(new Dimension(300, 35));
startDateField.setFont(dateFont);
// end date label
endDateLabel = new JLabel("End Date: ");
endDateLabel.setAlignmentX((float) 0.5);
endDateLabel.setFont(labelFont);
// end date field
endDateField = new JTextField();
endDateField.setAlignmentX((float) 0.5);
endDateField.setMaximumSize(new Dimension(300, 35));
endDateField.setPreferredSize(new Dimension(300, 35));
endDateField.setFont(dateFont);
// date panel
datePanel = new JPanel();
datePanel.setLayout(new BoxLayout(datePanel, BoxLayout.LINE_AXIS));
datePanel.add(Box.createHorizontalGlue());
datePanel.add(startDateLabel);
datePanel.add(startDateField);
datePanel.add(Box.createHorizontalGlue());
datePanel.add(endDateLabel);
datePanel.add(endDateField);
datePanel.add(Box.createHorizontalGlue());
// STAT PANEL * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// distinct label
distinctLabel = new JLabel("Number of Unduplicated Attendees: ");
distinctLabel.setAlignmentX((float) 0.5);
distinctLabel.setFont(labelFont);
// distinct field
distinctField = new JTextField();
distinctField.setAlignmentX((float) 0.5);
distinctField.setPreferredSize(new Dimension(200, 35));
distinctField.setFont(fieldFont);
distinctField.setEditable(false);
// distinct panel
distinctPanel = new JPanel();
distinctPanel.setLayout(new BoxLayout(distinctPanel, BoxLayout.LINE_AXIS));
distinctPanel.add(Box.createHorizontalGlue());
distinctPanel.add(distinctLabel);
distinctPanel.add(distinctField);
distinctPanel.add(Box.createHorizontalGlue());
// total label
totalLabel = new JLabel("Total Number of Visits: ");
totalLabel.setAlignmentX((float) 0.5);
totalLabel.setFont(labelFont);
// total field
totalField = new JTextField();
totalField.setAlignmentX((float) 0.5);
totalField.setPreferredSize(new Dimension(200, 35));
totalField.setFont(fieldFont);
totalField.setEditable(false);
// total panel
totalPanel = new JPanel();
totalPanel.setLayout(new BoxLayout(totalPanel, BoxLayout.LINE_AXIS));
totalPanel.add(Box.createHorizontalGlue());
totalPanel.add(totalLabel);
totalPanel.add(totalField);
totalPanel.add(Box.createHorizontalGlue());
// STAT PANEL * * * * * * * * * * * * * * * * * * * * * * * * * * * *
statPanel = new JPanel();
statPanel.setLayout(new BoxLayout(statPanel, BoxLayout.PAGE_AXIS));
statPanel.add(Box.createVerticalGlue());
statPanel.add(distinctPanel);
statPanel.add(Box.createVerticalGlue());
statPanel.add(totalPanel);
statPanel.add(Box.createVerticalGlue());
// BUTTON PANEL * * * * * * * * * * * * * * * * * * * * * * * * * * *
// report date button
reportDateBtn = new JButton("Create Report");
reportDateBtn.setFont(buttonFont);
reportDateBtn.setAlignmentX((float) 0.5);
reportDateBtn.setSize(400, 200);
// report all button
reportAllBtn = new JButton("Create Cumulative Report");
reportAllBtn.setFont(buttonFont);
reportAllBtn.setAlignmentX((float) 0.5);
reportAllBtn.setSize(400, 200);
// button panel
btnPanel = new JPanel();
btnPanel.setLayout(new BoxLayout(btnPanel, BoxLayout.PAGE_AXIS));
btnPanel.add(Box.createVerticalGlue());
btnPanel.add(reportDateBtn);
btnPanel.add(Box.createVerticalGlue());
btnPanel.add(reportAllBtn);
btnPanel.add(Box.createVerticalGlue());
// REPORT PANEL * * * * * * * * * * * * * * * * * * * * * * * * * * *
reportPanel = new JPanel();
reportPanel.add(statPanel);
reportPanel.add(btnPanel);
// CLOSE BUTTON * * * * * * * * * * * * * * * * * * * * * * * * * * *
closeBtn = new JButton("Close");
closeBtn.setFont(buttonFont);
closeBtn.setAlignmentY((float) 0.5);
closeBtn.setSize(400, 200);
// MAIN PANEL * * * * * * * * * * * * * * * * * * * * * * * * * * * *
pnl.add(titleLabel);
pnl.add(Box.createVerticalGlue());
pnl.add(datePanel);
pnl.add(Box.createVerticalGlue());
pnl.add(reportPanel);
pnl.add(Box.createVerticalGlue());
pnl.add(closeBtn);
//BUILD
frm.add(pnl);
frm.setPreferredSize(windowSize);
frm.setSize(windowSize);
// center on screen
frm.setLocation((screenSize.width / 2) - (windowSize.width / 2), (screenSize.height / 2) - (windowSize.height / 2));
frm.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
frm.setVisible(false);
frm.pack();
}
}