-
Notifications
You must be signed in to change notification settings - Fork 1
/
ViewMemberGUI.java
306 lines (275 loc) · 14.2 KB
/
ViewMemberGUI.java
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/*
ViewMemberGUI
The ViewMemberGUI has a bottom banner that allows the user to navigate to other pages.
The Fridge button navigates the user to the FridgeGUI
The Pantry button navigates the user to the PantryGUI
The Dashboard button navigates the user to the DashboardGUI
The Recipes button navigates the user to the RecipesGUI
The Household button navigates the user to the HouseholdGUI
The Shopping List button navigates the user to the ShoppingListGUI
The ViewMemberGUI will display the member's display name at the top of the screen
The ViewMemberGUI will display the member's household code under the household code label
The ViewMemberGUI will display if the member is the head of household or not
*/
/**
*
* @author joahp
*/
public class ViewMemberGUI extends javax.swing.JFrame
{
private Account account;
private Member member;
private Member viewMember;
public ViewMemberGUI()
{
initComponents();
}
public ViewMemberGUI(Account acc, Member mem, Member viewMem)
{
initComponents();
account = acc;
member = mem;
viewMember = viewMem;
seeMemberInformation();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents()
{
body = new javax.swing.JPanel();
memDNLabel = new javax.swing.JLabel();
householdCodeLabel = new javax.swing.JLabel();
botBanPanel = new javax.swing.JPanel();
botBanFridgeButton = new javax.swing.JButton();
botBanPantryButton = new javax.swing.JButton();
botBanDashboardButton = new javax.swing.JButton();
botBanRecipesButton = new javax.swing.JButton();
botBanHHButton = new javax.swing.JButton();
botBanSLButton = new javax.swing.JButton();
hhCodeLabel = new javax.swing.JLabel();
HeadOfHouseholdStatusLabel = new javax.swing.JLabel();
HoHStatusLabel = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
memDNLabel.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
memDNLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
memDNLabel.setText("Member Display Name");
memDNLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
householdCodeLabel.setText("Household Code:");
botBanFridgeButton.setText("Fridge");
botBanFridgeButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
botBanFridgeButtonActionPerformed(evt);
}
});
botBanPantryButton.setText("Pantry");
botBanPantryButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
botBanPantryButtonActionPerformed(evt);
}
});
botBanDashboardButton.setText("Dashboard");
botBanDashboardButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
botBanDashboardButtonActionPerformed(evt);
}
});
botBanRecipesButton.setText("Recipes");
botBanRecipesButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
botBanRecipesButtonActionPerformed(evt);
}
});
botBanHHButton.setText("Hosuehold");
botBanHHButton.setActionCommand("Household");
botBanHHButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
botBanHHButtonActionPerformed(evt);
}
});
botBanSLButton.setText("Shopping List");
botBanSLButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
botBanSLButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout botBanPanelLayout = new javax.swing.GroupLayout(botBanPanel);
botBanPanel.setLayout(botBanPanelLayout);
botBanPanelLayout.setHorizontalGroup(
botBanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(botBanPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(botBanFridgeButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(botBanPantryButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(botBanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(botBanDashboardButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(botBanSLButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(botBanRecipesButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(botBanHHButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(22, 22, 22))
);
botBanPanelLayout.setVerticalGroup(
botBanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, botBanPanelLayout.createSequentialGroup()
.addContainerGap(54, Short.MAX_VALUE)
.addGroup(botBanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(botBanFridgeButton)
.addComponent(botBanPantryButton)
.addComponent(botBanDashboardButton)
.addComponent(botBanRecipesButton)
.addComponent(botBanHHButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(botBanSLButton)
.addGap(16, 16, 16))
);
hhCodeLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
hhCodeLabel.setText("Household Code");
HeadOfHouseholdStatusLabel.setText("Head of Household Status:");
HoHStatusLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
HoHStatusLabel.setText("HoH Status");
javax.swing.GroupLayout bodyLayout = new javax.swing.GroupLayout(body);
body.setLayout(bodyLayout);
bodyLayout.setHorizontalGroup(
bodyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(memDNLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(bodyLayout.createSequentialGroup()
.addComponent(botBanPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(bodyLayout.createSequentialGroup()
.addGroup(bodyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(householdCodeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(hhCodeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 365, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(bodyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(bodyLayout.createSequentialGroup()
.addContainerGap()
.addComponent(HoHStatusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 365, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, bodyLayout.createSequentialGroup()
.addGap(36, 36, 36)
.addComponent(HeadOfHouseholdStatusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
bodyLayout.setVerticalGroup(
bodyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(bodyLayout.createSequentialGroup()
.addContainerGap()
.addComponent(memDNLabel)
.addGap(18, 18, 18)
.addComponent(householdCodeLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(hhCodeLabel)
.addGap(43, 43, 43)
.addComponent(HeadOfHouseholdStatusLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(HoHStatusLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(botBanPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(body, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(body, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
//switch to ShoppingListGUI when the shopping list button is clicked
private void botBanSLButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_botBanSLButtonActionPerformed
{//GEN-HEADEREND:event_botBanSLButtonActionPerformed
this.dispose();
ShoppingListGUI sl = new ShoppingListGUI(account, member);
sl.setVisible(true);
}//GEN-LAST:event_botBanSLButtonActionPerformed
//switch to FridgeGUI when the fridge button is clicked
private void botBanFridgeButtonActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
FridgeGUI fridge = new FridgeGUI(account, member);
fridge.setVisible(true);
}
//switch to PantryGUI when the pantry button is clicked
private void botBanPantryButtonActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
PantryGUI pantry = new PantryGUI(account, member);
pantry.setVisible(true);
}
//switch to DashboardGUI when the dashboard button is clicked
private void botBanDashboardButtonActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
DashboardGUI dashboard = new DashboardGUI(account, member);
dashboard.setVisible(true);
}
//switch to RecipesGUI when the recipes button is clicked
private void botBanRecipesButtonActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
RecipesGUI recipes = new RecipesGUI(account, member);
recipes.setVisible(true);
}
//switch to HouseholdGUI when the household button is clicked
private void botBanHHButtonActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
HouseholdGUI hh = new HouseholdGUI(account, member);
hh.setVisible(true);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel HeadOfHouseholdStatusLabel;
private javax.swing.JLabel HoHStatusLabel;
private javax.swing.JPanel body;
private javax.swing.JButton botBanDashboardButton;
private javax.swing.JButton botBanFridgeButton;
private javax.swing.JButton botBanHHButton;
private javax.swing.JPanel botBanPanel;
private javax.swing.JButton botBanPantryButton;
private javax.swing.JButton botBanRecipesButton;
private javax.swing.JButton botBanSLButton;
private javax.swing.JLabel hhCodeLabel;
private javax.swing.JLabel householdCodeLabel;
private javax.swing.JLabel memDNLabel;
// End of variables declaration//GEN-END:variables
//set the labels in the GUI to show viewMember information
private void seeMemberInformation()
{
//set Display Name of viewMember at the top
memDNLabel.setText(viewMember.getDisplayName());
//set account's Household Code under Household Code
hhCodeLabel.setText(account.getHouseholdCode());
//if viewMember is the current Head of Household
if (viewMember.isHoH())
{
HoHStatusLabel.setText(viewMember.getDisplayName() +
" is the current Head of Household");
}
//viewMember is not the current Head of Household
else
{
HoHStatusLabel.setText(viewMember.getDisplayName() +
" is not the current Head of Household");
}
}
}