-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFeeStructure.java
62 lines (48 loc) · 1.85 KB
/
FeeStructure.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
package university.management.system;
import javax.swing.*;
import java.awt.*;
import java.sql.*;
import javax.swing.plaf.OptionPaneUI;
import javax.swing.table.DefaultTableModel;
public class FeeStructure extends JFrame {
FeeStructure() {
setSize(1000, 700);
setLocation(250, 50);
setLayout(null);
getContentPane().setBackground(Color.WHITE);
JLabel heading = new JLabel("Fee Structure");
heading.setBounds(50, 10, 400, 30);
heading.setFont(new Font("Tahoma", Font.BOLD, 30));
add(heading);
JTable table = new JTable();
try {
Conn c = new Conn();
ResultSet rs = c.s.executeQuery("select * from fee");
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();
}
JScrollPane jsp = new JScrollPane(table);
jsp.setBounds(0, 60, 1000, 700);
add(jsp);
setVisible(true);
}
public static void main(String[] args) {
new FeeStructure();
}
}