- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalysisButtonPanel.java
More file actions
Latest commit
114 lines (93 loc) · 3.79 KB
/
Copy pathAnalysisButtonPanel.java
File metadata and controls
114 lines (93 loc) · 3.79 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
importjava.awt.Color;
importjava.awt.GridLayout;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjavax.swing.BorderFactory;
importjavax.swing.JButton;
importjavax.swing.JPanel;
importjavax.swing.border.Border;
publicclassAnalysisButtonPanelimplementsGUI {
privatestaticAnalysisButtonPanelpanel;
privateJButtonshowUserTotal;
privateJButtonshowGroupTotal;
privateJButtonshowMessagesTotal;
privateJButtonshowPositivePercentage;
privateJPanelanalysisPanel;
//singleton so only one analysis panel exists
publicstaticAnalysisButtonPanelpanel() {
if (panel == null) {
panel = newAnalysisButtonPanel();
}
returnpanel;
}
publicAnalysisButtonPanel() {
}
//initialize the panel
publicvoidinitialize() {
this.showUserTotal = newJButton("Total Users");
this.showGroupTotal = newJButton("Total Groups");
this.showMessagesTotal = newJButton("Total Messages");
this.showPositivePercentage = newJButton("Total Positivity");
this.analysisPanel = newJPanel();
formatPanel();
}
//format the panel
publicvoidformatPanel() {
BorderanalysisBorder = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLUE), "Analysis");
analysisPanel.setBorder(analysisBorder);
analysisPanel.setLayout(newGridLayout(2, 2));
analysisPanel.add(showUserTotal);
analysisPanel.add(showGroupTotal);
analysisPanel.add(showMessagesTotal);
analysisPanel.add(showPositivePercentage);
setUpButtonActions();
}
//get the show total users button
publicJButtongetShowTotalUsersButton() {
returnshowUserTotal;
}
//get the show total groups button
publicJButtongetShowTotalGroupsButton() {
returnshowGroupTotal;
}
//get the show total messages button
publicJButtongetShowMessagesTotalButton() {
returnshowMessagesTotal;
}
//get the show positive percentage button
publicJButtongetShowPositivePercentageButton() {
returnshowPositivePercentage;
}
//set up the button actions
publicvoidsetUpButtonActions() {
getShowTotalUsersButton().addActionListener(newActionListener() {
publicvoidactionPerformed(ActionEvente) {
inttotalUsers = Admin.getAdmin().getTotalUsers();
AdminControlPanel.getFrame().showMessage("Total Users: " + totalUsers);
}
});
getShowTotalGroupsButton().addActionListener(newActionListener() {
publicvoidactionPerformed(ActionEvente) {
inttotalGroups = Admin.getAdmin().getTotalGroups();
AdminControlPanel.getFrame().showMessage("Total Groups: " + totalGroups);
}
});
getShowMessagesTotalButton().addActionListener(newActionListener() {
publicvoidactionPerformed(ActionEvente) {
inttotalMessages = Admin.getAdmin().getTotalMessages();
AdminControlPanel.getFrame().showMessage("Total Messages: " + totalMessages);
}
});
getShowPositivePercentageButton().addActionListener(newActionListener() {
publicvoidactionPerformed(ActionEvente) {
doublepositivePercentage = Admin.getAdmin().getPositivityPercentage();
AdminControlPanel.getFrame().showMessage("Positive Percentage: " + positivePercentage + "%");
}
});
}
//render the panel
publicJPanelrender() {
initialize();
returnthis.analysisPanel;
}
}