-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathViewStudents.java
98 lines (81 loc) · 2.57 KB
/
ViewStudents.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
package regPrototype;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.text.html.HTMLDocument.Iterator;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JTable;
import javax.swing.JTextPane;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import java.awt.List;
import java.util.Objects;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class ViewStudents extends JFrame {
private JPanel contentPane;
private DefaultListModel<String> listModel;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ViewStudents frame = new ViewStudents();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public ViewStudents() {
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setForeground(new Color(0, 0, 0));
contentPane.setBackground(new Color(0, 102, 153));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblViewStudents = new JLabel("View Students");
lblViewStudents.setForeground(new Color(255, 255, 255));
lblViewStudents.setBounds(128, 11, 150, 14);
contentPane.add(lblViewStudents);
//Gets the current list of all students and fills the listModel for the list element, which will display all of them.
java.util.Iterator<Student> it = homePage.getDatabase().allStudents.iterator();
listModel = new DefaultListModel<String>();
//Header of the list
listModel.addElement("ID First Name Last Name GPA");
while(it.hasNext()){
Student current = it.next();
listModel.addElement(current.toString());
}
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 38, 414, 212);
contentPane.add(scrollPane);
JList<String> list = new JList<String>(listModel);
scrollPane.setViewportView(list);
JButton btnBack = new JButton("Back");
btnBack.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
new registrarHome().setVisible(true);
}
});
btnBack.setBounds(335, 7, 89, 23);
contentPane.add(btnBack);
}
}