-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakeReportPage.java
184 lines (158 loc) · 6.64 KB
/
MakeReportPage.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
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
/**
* This class is the graphical implementation of the make report page. On this page, customers can report suspicious
* activity on their account and describe their situation. This is sent to one of the admins in the system (initialized
* in BankAutomated) and is reviewed by them.
*/
public class MakeReportPage extends JFrame implements ActionListener
{
// Constants
static final int WIDTH = 1920;
static final int LENGTH = 1080;
// Objects
BankAutomated BA;
HomePage home;
CA customer;
// GUI Components for MakeReportPage
private final JButton backToHome;
private final JButton completeButton;
private final JTextArea reportField;
/**
* MakeReportPage Constructor, this frame creates all the frame specifications for the make report page
* @param home HomePage object, for the user to return to if they select 'Back To Home'
* @param BA BankAutomated object, to process logout if user exits the system
* @param customer CA object, the customer that's logged in
*/
public MakeReportPage(HomePage home, BankAutomated BA, CA customer)
{
// Set title of the frame
this.setTitle("Report Suspicious Activity");
this.setLayout(null);
this.home = home;
this.BA = BA;
this.customer = customer;
// GUI Components
Border emptyBorder = BorderFactory.createEmptyBorder();
Border border = BorderFactory.createLineBorder(Color.BLACK, 3);
// GUI Components for report
JLabel input = new JLabel("Please describe the situation:");
input.setFont(new Font("Raleway", Font.BOLD, 22));
input.setBackground(Color.white);
input.setBounds(300, 150, 400, 50);
this.add(input);
// GUI Components for report field
reportField = new JTextArea();
reportField.setFont(new Font("SansSerif", Font.PLAIN, 22));
reportField.setBackground(Color.white);
reportField.setBounds(300, 200, 700, 300);
// GUI Components for scroll bar
JScrollPane scroll = new JScrollPane(reportField);
scroll.setBounds(300, 200, 700, 300);
scroll.setBorder(border);
reportField.setEditable(true);
this.add(scroll);
// GUI Components for submit button
completeButton = new JButton("Submit Report");
completeButton.setFont(new Font("SansSerif", Font.PLAIN, 22));
completeButton.setBounds(475, 525, 350, 40);
completeButton.setBackground(Color.black);
completeButton.setForeground(Color.white);
completeButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
completeButton.setBorder(emptyBorder);
completeButton.addActionListener(this);
this.add(completeButton);
// GUI Components for back to home button
backToHome = new JButton("Back to Home");
backToHome.setFont(new Font("SansSerif", Font.PLAIN, 22));
backToHome.setBounds(475, 575, 350, 50);
backToHome.setBackground(Color.white);
backToHome.setForeground(new Color(57, 107, 170));
backToHome.setCursor(new Cursor(Cursor.HAND_CURSOR));
backToHome.setContentAreaFilled(false);
backToHome.setFocusPainted(false);
backToHome.setBorder(emptyBorder);
backToHome.setContentAreaFilled(false);
backToHome.addActionListener(this);
this.add(backToHome);
// Window Listener, logout when window is closed
this.addWindowListener(new WindowEventHandler() {
@Override
public void windowClosing(WindowEvent evt) {
//BA.logout (logic.logout) would be called here
//Write all changes to the file
BA.logout();
Window[] windows = Window.getWindows();
for (Window window : windows) {
window.dispose();
}
System.exit(0);
}
});
// Set background color
this.getContentPane().setBackground(Color.white);
this.getRootPane().setDefaultButton(completeButton);
this.setSize(WIDTH, LENGTH);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(false);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
/**
* paint method, overrides the JFrame paint method in order to allow for custom graphical design
* @param g Graphics object
*/
public void paint(Graphics g)
{
super.paint(g);
// Set background color
Graphics2D g2 = (Graphics2D) g;
Color myRed = new Color(230, 30, 30);
Color myBlack = new Color(160, 32, 32);
GradientPaint redToBlack = new GradientPaint(0, 0, myRed, 0, 150, myBlack);
g2.setPaint(redToBlack);
g2.fillRect(0, 0, WIDTH+1, 150);
// Set font and color
Font regFont = new Font("Raleway", Font.BOLD, 60);
g2.setFont(regFont);
g2.setColor(new Color(250, 185, 60));
g2.drawString("Report Suspicious Activity To Admins", 25, 110);
}
/**
* actionPerformed method (implementing ActionListener). It displays different options depending on what the user
* clicks on in the homepage, and it controls which page to display next depending on that.
* @param e ActionEvent object, which listens and keeps track of any button clicks
*/
@Override
public void actionPerformed(ActionEvent e)
{
// If back to home button is clicked, go back to home page
if (e.getSource() == backToHome)
{
this.setVisible(false);
home.setVisible(true);
}
// If submit button is clicked, submit report
else if (e.getSource() == completeButton)
{
String reportDescription = reportField.getText();
// If no description is entered, display error message
if (reportDescription.equals(""))
{
JOptionPane.showMessageDialog(this, "Please describe the situation before submitting.");
}
// If description is entered, submit report
else
{
JOptionPane.showMessageDialog(this, "Thank you for reporting suspicious on your" +
" account. An admin will review it and\ncontact you shortly as per your notification preferences.");
BA.makeReport(customer, reportDescription);
this.setVisible(false);
home.setVisible(true);
}
}
}
}