-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain_Menu_Panel.java
More file actions
executable file
·242 lines (185 loc) · 7.4 KB
/
Main_Menu_Panel.java
File metadata and controls
executable file
·242 lines (185 loc) · 7.4 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
237
238
239
240
241
242
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/*****************************************************************************************************
* Represents an instance of a main menu to display on the JFrame.
*****************************************************************************************************/
public class Main_Menu_Panel extends JPanel
{
/* Pointer to the main java window to access its get() methods for other panels */
protected Hospital_Frame hospital_frame;
/* Panels displaying different options to the user */
private JPanel access_panel, insert_delete_panel;
/*********************************************************************************
* Main constructor used when creating a main menu.
*********************************************************************************/
public Main_Menu_Panel(Hospital_Frame frame)
{
setLayout(new GridLayout(2, 4));
// establish a reference to the frame to change the displayed panel
this.hospital_frame = frame;
add(new Centered_Text_Panel("Access Records for: "));
add(access_panel = new Records_Panel());
add(new Centered_Text_Panel("Insert/Delete Records for: "));
add(insert_delete_panel = new Update_Panel());
}
/*********************************************************************************
* Upper half of the main menu, displaying the buttons for accessing and modifying
* the relations: patient, nurse, doctor.
*********************************************************************************/
private class Records_Panel extends JPanel
{
/*********************************************************************************
* Main constructor used when creating Records_Panel.
*********************************************************************************/
public Records_Panel()
{
setLayout(new GridBagLayout());
add(new Patient_Button());
add(new Doctor_Button());
add(new Nurse_Button());
}
/******************************************************************************
* Patient button for Records_Panel class.
******************************************************************************/
private class Patient_Button extends JButton
{
/******************************************************************
* Main constructor for Patient_Button
******************************************************************/
public Patient_Button()
{
// name the button
super("Patient");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
hospital_frame.changeScreen( new Patient_Menu_Panel(hospital_frame) );
}
});
}
} // end class Patient_Button
/******************************************************************************
* Doctor button for Records_Panel class.
******************************************************************************/
private class Doctor_Button extends JButton
{
/******************************************************************
* Main constructor for Doctor_Button
******************************************************************/
public Doctor_Button()
{
// name the button
super("Doctor");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
hospital_frame.changeScreen( new Doctor_Menu_Panel(hospital_frame) );
}
});
}
} // end class Doctor_Button
/******************************************************************************
* Nurse button for Records_Panel class.
******************************************************************************/
private class Nurse_Button extends JButton
{
/******************************************************************
* Main constructor for Nurse_Button
******************************************************************/
public Nurse_Button()
{
// name the button
super("Nurse");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
hospital_frame.changeScreen( new Nurse_Menu_Panel(hospital_frame) );
}
});
}
} // end class Nurse_Button
} // end Records class
/*********************************************************************************
* Bottom half of the main menu, displaying a dropdown menu for inserting and deleting
* in the relations "Patient", "Nurse", "Doctor", "Medication", "Prescription",
* "Treatment", "Procedure".
*********************************************************************************/
private class Update_Panel extends JPanel
{
/* Drop down menu for selecting which relation to insert into */
private JComboBox relation_selection_combo_box;
/* Options for the user to select from in the drop down menu */
private String[] relation_selection_options = {"Patient", "Nurse", "Doctor", "Record", "Prescription", "Treatment", "Procedure"};
/*********************************************************************************
* Main constructor used when creating a Update_Panel.
*********************************************************************************/
public Update_Panel()
{
setLayout(new GridBagLayout());
relation_selection_combo_box = new JComboBox(relation_selection_options);
add(relation_selection_combo_box);
add(new Submit_Button());
}
/******************************************************************************
* Submit button for Update_Panel class.
******************************************************************************/
private class Submit_Button extends JButton
{
/******************************************************************
* Main constructor for Submit_Button
******************************************************************/
public Submit_Button()
{
// name the button
super("Submit");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
fetchDropDownMenuSelection();
}
});
}
}
/*********************************************************************************
* Get the selected relation from the drop down menu and change the screen to the
* panel for inserting into that selection
*********************************************************************************/
private void fetchDropDownMenuSelection()
{
String selection = relation_selection_combo_box.getSelectedItem().toString();
// Switch the screen to the selected option
switch(selection)
{
case "Patient":
hospital_frame.changeScreen(new Insert_Patient_Menu_Panel(hospital_frame));
break;
case "Nurse":
hospital_frame.changeScreen(new Insert_Nurse_Menu_Panel(hospital_frame));
break;
case "Doctor":
hospital_frame.changeScreen(new Insert_Doctor_Menu_Panel(hospital_frame));
break;
case "Prescription":
hospital_frame.changeScreen(new Prescription_Menu_Panel(hospital_frame));
break;
case "Treatment":
hospital_frame.changeScreen(new Treatment_Menu_Panel(hospital_frame));
break;
case "Record":
hospital_frame.changeScreen(new Insert_Record_Menu_Panel(hospital_frame));
break;
case "Procedure":
hospital_frame.changeScreen(new Procedure_Menu_Panel(hospital_frame));
break;
default:
hospital_frame.changeScreen(new Insert_Doctor_Menu_Panel(hospital_frame));
break;
}
}
} // end update panel class
} // end main menu class