-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInsert_Doctor_Menu_Panel.java
More file actions
executable file
·116 lines (85 loc) · 3.44 KB
/
Insert_Doctor_Menu_Panel.java
File metadata and controls
executable file
·116 lines (85 loc) · 3.44 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/*****************************************************************************************************
* A menu displayed to the user to insert a new doctor into the database.
*****************************************************************************************************/
public class Insert_Doctor_Menu_Panel extends JPanel
{
/* Pointer to the main java window to access its get() methods for other panels */
private Hospital_Frame main_frame;
/* Text fields for the user to enter intput data */
private JTextField ssn_field, first_name_field, m_initial_field, last_name_field, code_field;
/* String to get input data from fields */
private String input;
/*********************************************************************************
* Main constructor used for setting up the Insert_Doctor_Menu_Panel.
*********************************************************************************/
public Insert_Doctor_Menu_Panel(Hospital_Frame frame)
{
this.main_frame = frame;
setLayout(new GridLayout(7, 2));
//setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
initializeTextFields();
add(new JLabel("Enter information of doctor to be added: "));
add(new JLabel(""));
add(new JLabel(" SSN:"));
add(ssn_field);
add(new JLabel(" First Name:"));
add(first_name_field);
add(new JLabel(" Middle Initial:"));
add(m_initial_field);
add(new JLabel(" Last Name:"));
add(last_name_field);
add(new JLabel(" Department:"));
add(code_field);
add(new Main_Menu_Button(frame));
add(new Submit_Button());
}
/*********************************************************************************
* Initializes the text fields for Insert_Doctor_Menu_Panel.
*********************************************************************************/
private void initializeTextFields()
{
ssn_field = new JTextField(6);
first_name_field = new JTextField(6);
m_initial_field = new JTextField(1);
last_name_field = new JTextField(6);
code_field = new JTextField(6);
}
/******************************************************************************
* Submit button for Insert_Doctor_Menu_Panel class.
******************************************************************************/
private class Submit_Button extends JButton
{
/******************************************************************
* Main constructor for Submit_Button
******************************************************************/
public Submit_Button()
{
super("Submit");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
// get input from ssn field into ssn string variable
loadInput();
Doctor.insert(input);
// display a new popup saying insertion was successful?
JOptionPane.showMessageDialog(null,"Submitted");
}
});
}
/******************************************************************
* Load input from ssn field into corresponding string variable and
* return that string.
******************************************************************/
private String loadInput()
{
// get input from textfields and load them into a single string
input = ssn_field.getText() + "\t" + first_name_field.getText() + "\t" + m_initial_field.getText() + "\t" +
last_name_field.getText() + "\t" + code_field.getText();
return input;
}
} // end Submit_Button class
} // end insert doctor menu class