-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompStatus.java
66 lines (56 loc) · 1.98 KB
/
compStatus.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
import java.awt.GridLayout;
import java.awt.Dialog.ModalityType;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class compStatus implements ActionListener {
private JDialog win;
private compFile cfile;
private int compNum;
private JTextField tfCompNum;
private JTextArea taStatus;
public compStatus(compFile cfile) {
win = new JDialog();
win.setModalityType(ModalityType.APPLICATION_MODAL);
win.setTitle("Complaint Status");
win.setSize(500, 300);
win.setLayout(new GridLayout(2, 1));
this.cfile = cfile;
tfCompNum = new JTextField(20);
tfCompNum.addActionListener(this);
taStatus = new JTextArea(10, 40);
taStatus.setEditable(false);
JPanel panel1 = new JPanel();
panel1.add(new JLabel("Enter Complaint No. : "));
panel1.add(tfCompNum);
JPanel panel2 = new JPanel();
panel2.add(new JLabel("Status "));
panel2.add(new JScrollPane(taStatus));
win.add(panel1);
win.add(panel2);
win.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
try {
this.compNum = Integer.parseInt(tfCompNum.getText());
complaint comp = cfile.getComp(compNum);
if (comp == null) {
taStatus.setText("Invalid Complaint No.");
} else {
String status = "Type: " + comp.getType() + "\n"
+ "Priority: " + comp.getPriority() + "\n"
+ "Email: " + comp.getEmail() + "\n"
+ "Solution: " + cfile.getSoln(compNum);
taStatus.setText(status);
}
} catch (Exception exc) {
taStatus.setText("Invalid Complaint No.");
}
}
}