-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDoctor.java
265 lines (222 loc) · 8.32 KB
/
Doctor.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
package client;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JTextPane;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Font;
import java.awt.Point;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JScrollPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Doctor extends JFrame {
static JPanel contentPane;
static public JTextField medicine;
static public JTextField name;
static public JTextField sex;
static public JTextField age;
static public JTextField count;
static public JTextArea wait;
static public String currentString="";
static public JTextArea content;
static public JTextField ID;
/**
* Launch the application.
*/
// public static void main(String[] args) {
// EventQueue.invokeLater(new Runnable() {
// public void run() {
// try {
// Doctor frame = new Doctor("doctorName","department");
// frame.setVisible(true);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// });
// }
/**
* Create the frame.
*/
public Doctor(String doctorName,String depart,Point p) {
this.setLocation(p);
this.setTitle("医生名字:"+doctorName+" 所在科室:"+depart);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//setBounds(100, 100, 650, 450);
this.setSize(650, 450);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
//JScrollPane scroll = new JScrollPane();
//把定义的JTextArea放到JScrollPane里面去
JLabel label = new JLabel("\u5F53\u524D\u7B49\u5F85\u961F\u5217");
label.setFont(new Font("微软雅黑", Font.PLAIN, 25));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setBounds(377, 10, 179, 30);
contentPane.add(label);
medicine = new JTextField();
medicine.setBounds(284, 304, 136, 21);
contentPane.add(medicine);
medicine.setColumns(10);
JLabel label_1 = new JLabel("\u5F53\u524D\u8BCA\u65AD\u7684\u4EBA");
label_1.setHorizontalAlignment(SwingConstants.CENTER);
label_1.setFont(new Font("微软雅黑", Font.PLAIN, 25));
label_1.setBounds(39, 10, 179, 30);
contentPane.add(label_1);
JLabel label_2 = new JLabel("\u59D3\u540D\uFF1A");
label_2.setFont(new Font("微软雅黑", Font.PLAIN, 18));
label_2.setBounds(25, 62, 54, 15);
contentPane.add(label_2);
name = new JTextField();
name.setEditable(false);
name.setColumns(10);
name.setBounds(138, 61, 106, 21);
contentPane.add(name);
sex = new JTextField();
sex.setEditable(false);
sex.setColumns(10);
sex.setBounds(137, 90, 106, 21);
contentPane.add(sex);
age = new JTextField();
age.setEditable(false);
age.setColumns(10);
age.setBounds(138, 119, 106, 21);
contentPane.add(age);
JLabel label_3 = new JLabel("\u5E74\u9F84\uFF1A");
label_3.setFont(new Font("微软雅黑", Font.PLAIN, 18));
label_3.setBounds(25, 125, 54, 15);
contentPane.add(label_3);
JLabel label_4 = new JLabel("\u6027\u522B\uFF1A");
label_4.setFont(new Font("微软雅黑", Font.PLAIN, 18));
label_4.setBounds(24, 95, 54, 16);
contentPane.add(label_4);
count = new JTextField();
count.setBounds(460, 304, 141, 21);
contentPane.add(count);
count.setColumns(10);
JLabel label_5 = new JLabel("\u8F93\u5165\u836F\u54C1\u6216\u6536\u8D39\u9879\u76EE");
label_5.setHorizontalAlignment(SwingConstants.CENTER);
label_5.setFont(new Font("微软雅黑", Font.PLAIN, 18));
label_5.setBounds(267, 275, 179, 19);
contentPane.add(label_5);
JLabel label_6 = new JLabel("\u8F93\u5165\u6570\u91CF");
label_6.setHorizontalAlignment(SwingConstants.CENTER);
label_6.setFont(new Font("微软雅黑", Font.PLAIN, 18));
label_6.setBounds(460, 275, 136, 19);
contentPane.add(label_6);
content = new JTextArea();
content.setEditable(false);
content.setBounds(13, 227, 231, 174);
contentPane.add(content);
JLabel label_7 = new JLabel("\u5DF2\u6DFB\u52A0\u7684\u5185\u5BB9");
label_7.setHorizontalAlignment(SwingConstants.CENTER);
label_7.setFont(new Font("微软雅黑", Font.PLAIN, 25));
label_7.setBounds(39, 187, 179, 30);
contentPane.add(label_7);
JButton cancel = new JButton("\u6E05\u7A7A");
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
content.setText("");
ClientDoctorThread.sendMedicineInfo="";
}
});
cancel.setBounds(360, 350, 85, 30);
contentPane.add(cancel);
JButton next = new JButton("\u5B8C\u6210");
next.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(currentString.equals("")){
return;
}
if(ClientDoctorThread.myWaitPatient.size()==0){
return;
}
String str=name.getText()+","+sex.getText()+","+age.getText()+","+ClientDoctorThread.myWaitPatient.get(0).id+"#";
ClientDoctorThread.sendMedicineInfo(str+ClientDoctorThread.sendMedicineInfo);
System.out.println(str+ClientDoctorThread.sendMedicineInfo);
ClientDoctorThread.myWaitPatient.remove(0);
if(ClientDoctorThread.myWaitPatient.size()!=0){
Doctor.name.setText(ClientDoctorThread.myWaitPatient.get(0).name);
Doctor.sex.setText(ClientDoctorThread.myWaitPatient.get(0).sex);
Doctor.age.setText(ClientDoctorThread.myWaitPatient.get(0).age);
Doctor.ID.setText(ClientDoctorThread.myWaitPatient.get(0).id);
}
else{
Doctor.name.setText("");
Doctor.sex.setText("");
Doctor.age.setText("");
Doctor.ID.setText("");
}
ClientDoctorThread.updatePaitenInfo();
}
});
next.setBounds(450, 350, 85, 30);
contentPane.add(next);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(279, 50, 345, 203);
contentPane.add(scrollPane);
wait = new JTextArea();
scrollPane.setViewportView(wait);
wait.setEditable(false);
//分别设置水平和垂直滚动条自动出现
//scroll.setHorizontalScrollBarPolicy(
//JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
//分别设置水平和垂直滚动条总是出现
//scrollPane.setHorizontalScrollBarPolicy(
//JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
//scrollPane.setVerticalScrollBarPolicy(
//JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
//分别设置水平和垂直滚动条总是隐藏
//scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
//scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
//wait.setCaretPosition(wait.getText().length());//设置textarea中垂直滚动条始终显示在最下方
JButton addBtn = new JButton("\u6DFB\u52A0");
addBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String name=medicine.getText();
String sum=count.getText();
if(name.equals("")||sum.equals("")){
JOptionPane.showMessageDialog(contentPane,"输入错误");
return;
}
//info=name(patient),sex,age,id#medicine,count-medicine,count....
if((ClientDoctorThread.myMedicineInfo.get(name)!=null)&&(sum.matches("[0-9][0-9]*"))){
currentString+=name+"\t"+sum+"\n";
content.setText(currentString);
ClientDoctorThread.sendMedicineInfo+=(name+","+sum+"-");
System.out.println(ClientDoctorThread.sendMedicineInfo);
}
}
});
addBtn.setBounds(270, 350, 85, 30);
contentPane.add(addBtn);
JButton button = new JButton("\u8DF3\u8FC7");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
ClientDoctorThread.nextFunctioin();
}
});
button.setBounds(540, 350, 85, 30);
contentPane.add(button);
JLabel label_8 = new JLabel("\u75C5\u4EBA\u53F7\u7801\uFF1A");
label_8.setFont(new Font("微软雅黑", Font.PLAIN, 18));
label_8.setBounds(25, 150, 106, 17);
contentPane.add(label_8);
ID = new JTextField();
ID.setEditable(false);
ID.setColumns(10);
ID.setBounds(138, 149, 106, 21);
contentPane.add(ID);
}
}