-
Notifications
You must be signed in to change notification settings - Fork 3
/
ExaminationDetails.java
106 lines (87 loc) · 3.3 KB
/
ExaminationDetails.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
package university.management.system;
import java.awt.*;
import javax.swing.*;
import java.sql.*;
//import net.proteanit.sql.DbUtils;
import java.awt.event.*;
import javax.swing.plaf.OptionPaneUI;
import javax.swing.table.DefaultTableModel;
public class ExaminationDetails extends JFrame implements ActionListener {
JTextField search;
JButton submit, cancel;
JTable table;
ExaminationDetails() {
setSize(1000, 475);
setLocation(300, 100);
setLayout(null);
getContentPane().setBackground(Color.WHITE);
JLabel heading = new JLabel("Check Result");
heading.setBounds(80, 15, 400, 50);
heading.setFont(new Font("Tahoma", Font.BOLD, 24));
add(heading);
search = new JTextField();
search.setBounds(80, 90, 200, 30);
search.setFont(new Font("Tahoma", Font.PLAIN, 18));
add(search);
submit = new JButton("Result");
submit.setBounds(300, 90, 120, 30);
submit.setBackground(Color.BLACK);
submit.setForeground(Color.WHITE);
submit.addActionListener(this);
submit.setFont(new Font("Tahoma", Font.BOLD, 15));
add(submit);
cancel = new JButton("Back");
cancel.setBounds(440, 90, 120, 30);
cancel.setBackground(Color.BLACK);
cancel.setForeground(Color.WHITE);
cancel.addActionListener(this);
cancel.setFont(new Font("Tahoma", Font.BOLD, 15));
add(cancel);
table = new JTable();
table.setFont(new Font("Tahoma", Font.PLAIN, 16));
JScrollPane jsp = new JScrollPane(table);
jsp.setBounds(0, 130, 1000, 310);
add(jsp);
try {
Conn c = new Conn();
ResultSet rs = c.s.executeQuery("select * from student");
ResultSetMetaData metaData = rs.getMetaData();
int columnCount = metaData.getColumnCount();
String[] columnNames = new String[columnCount];
for (int i = 1; i <= columnCount; i++) {
columnNames[i - 1] = metaData.getColumnName(i);
}
DefaultTableModel model = new DefaultTableModel(columnNames, 0);
while (rs.next()) {
String[] rowData = new String[columnCount];
for (int i = 1; i <= columnCount; i++) {
rowData[i - 1] = rs.getString(i); // Adjust getString for other data types
}
model.addRow(rowData);
}
table.setModel(model);
//
// table.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
e.printStackTrace();
}
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent me) {
int row = table.getSelectedRow();
search.setText(table.getModel().getValueAt(row, 2).toString());
}
});
setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == submit) {
setVisible(false);
new Marks(search.getText());
} else {
setVisible(false);
}
}
public static void main(String[] args) {
new ExaminationDetails();
}
}