-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewWindow.java
59 lines (51 loc) · 1.96 KB
/
ViewWindow.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
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;
import java.awt.FlowLayout;
import java.awt.Container;
import java.awt.TextArea;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.util.List;
class ViewWindow extends JFrame {
Container c;
TextArea taRecords;
JButton btnBack;
ViewWindow(List<Student> studentList) {
c = getContentPane();
c.setLayout(new FlowLayout());
c.setBackground(new Color(199, 255, 253));
taRecords = new TextArea(30, 60);
btnBack = new JButton("Back");
btnBack.setIcon(new ImageIcon("icons/back.png"));
taRecords.setFont(new Font("Calibri", Font.BOLD, 12));
btnBack.setFont(new Font("Calibri", Font.BOLD, 24));
btnBack.setBackground(new Color(255, 221, 201));
c.add(taRecords);
c.add(btnBack);
if (!studentList.isEmpty()) {
for (Student s: studentList) {
taRecords.append("Roll No.: " + s.rollNumber);
taRecords.append("\nName: " + s.name);
taRecords.append("\nPhysics marks (out of 100): " + s.physicsMarks);
taRecords.append("\nChemistry marks (out of 100): " + s.chemistryMarks);
taRecords.append("\nMaths marks (out of 100): " + s.mathsMarks + "\n\n");
}
} else {
JOptionPane.showMessageDialog(c, "No records in the database.", "Empty Database", JOptionPane.WARNING_MESSAGE);
}
ActionListener btnBackAl = (ae) -> {
MainWindow mw = new MainWindow();
dispose();
};
btnBack.addActionListener(btnBackAl);
setTitle("View Students' Records");
setSize(580, 580);
setIconImage(new ImageIcon("icons/window.png").getImage());
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}