-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchScore.java
More file actions
114 lines (95 loc) · 2.97 KB
/
SearchScore.java
File metadata and controls
114 lines (95 loc) · 2.97 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
package KYUTES;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import java.awt.Font;
public class SearchScore implements ActionListener {
public JFrame frame;
private JPanel contentPane;
JButton backButt;
JComboBox<String> comboBox;
JTextArea scoreArea;
/**
* Launch the application.
*
* public static void main(String[] args) { EventQueue.invokeLater(new
* Runnable() { public void run() { try { SearchScore window = new
* SearchScore(); window.frame.setVisible(true); } catch (Exception e) {
* e.printStackTrace(); } } }); }
*
* /** Create the application.
*/
public SearchScore() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 1000, 800);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
frame.setLocationRelativeTo(null);
JPanel panel = new JPanel();
panel.setBounds(0, 0, 984, 761);
frame.getContentPane().add(panel);
panel.setLayout(null);
backButt = new JButton("back");
backButt.setBounds(851, 705, 87, 23);
panel.add(backButt);
backButt.addActionListener(this);
comboBox = new JComboBox<String>();
comboBox.setBounds(180, 705, 571, 23);
panel.add(comboBox);
comboBox.addItem("choose examination");
comboBox.addItem("mid exam");
comboBox.addItem("final exam");
comboBox.addActionListener(this);
JLabel lblNewLabel = new JLabel("choose quiz");
lblNewLabel.setFont(new Font("Arial", Font.PLAIN, 20));
lblNewLabel.setBounds(51, 705, 119, 23);
panel.add(lblNewLabel);
scoreArea = new JTextArea();
scoreArea.setBounds(51, 25, 887, 662);
panel.add(scoreArea);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == backButt) {
frame.dispose();
/*
* try { TeacherUI window = new TeacherUI(TeacherUI.userName);
* window.frame.setVisible(true); } catch (Exception e1) { // TODO
* Auto-generated catch block e1.printStackTrace(); }
*/
}
if (e.getSource() == comboBox) {
String scoretxt = "";
String examSelect = (String) comboBox.getSelectedItem();
if (examSelect.equals("mid exam")) {
try {
Connection conn = UseDatabase.getConnection();
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("Select * from `midExamScore`");
while (rs.next()) {
scoretxt += rs.getString("name") + "\t\t" + rs.getString("score") + "\n";
}
scoreArea.setText(scoretxt);
} catch (Exception e1) {
System.out.println(e1);
}
}
}
}
}