-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatController.java
81 lines (46 loc) · 1.58 KB
/
patController.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
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
public class patController implements ActionListener, ListSelectionListener{
patModel M = null;
patView V = null;
login loginPage = null;
homeView homePage = null;
int counter = 0;
public patController(patModel modelRef, patView viewRef, login loginRef, homeView homeRef){
M = modelRef;
V = viewRef;
loginPage = loginRef;
homePage = homeRef;
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("createNew")){
M.newEntry();
}
else if (e.getActionCommand().equals("delete")){
String id = (String) V.getTable().getValueAt(V.getTable().getSelectedRow(), 0);
M.delete(id);
}
else if (e.getActionCommand().equals("save")){
String id = (String) V.getTable().getValueAt(V.getTable().getSelectedRow(), 0);
M.save(id);
}
else if (e.getActionCommand().equals("logout")){
V.setVisible(false);
loginPage.setVisible(true);
}
else if (e.getActionCommand().equals("backHome")){
V.setVisible(false);
homePage.setVisible(true);
}
}
public void valueChanged(ListSelectionEvent e) {
counter ++;
if (counter == 2){
String id = (String) V.getTable().getValueAt(V.getTable().getSelectedRow(), 0);
M.select(id);;
counter = 0;
}
}
}