-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentManagementSystemGUI.java
More file actions
112 lines (97 loc) · 3.73 KB
/
Copy pathStudentManagementSystemGUI.java
File metadata and controls
112 lines (97 loc) · 3.73 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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package studentmanagementsystem;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
/**
*
* @author G Supriya
*/
public class StudentManagementSystemGUI extends JFrame{
public StudentManagementSystemGUI() {
setTitle("Student Management System");
setSize(800, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
JPanel headerPanel = new JPanel();
headerPanel.setBackground(Color.pink);
headerPanel.setPreferredSize(new Dimension(800, 50)); // Match frame width
headerPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); // Center components
JLabel headerLabel = new JLabel("Student Management System");
headerLabel.setFont(new Font("Arial", Font.BOLD, 20));
headerLabel.setForeground(Color.WHITE);
headerLabel.setHorizontalAlignment(SwingConstants.CENTER);
headerPanel.add(headerLabel);
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(5, 2, 10, 10));
JButton addButton = new JButton("Add Student");
JButton updateButton = new JButton("Update Student's single field");
JButton updateButtonAll = new JButton("Update Student's All Details");
JButton deleteButton = new JButton("Delete Student");
JButton viewButton = new JButton("View Students");
addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new AddStudentWindow().setVisible(true);
dispose();
}
});
updateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new updateStudent().setVisible(true);
dispose();
}
});
updateButtonAll.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new StudentUpdateApp().setVisible(true);
dispose();
}
});
deleteButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new deletestudent().setVisible(true);
dispose();
}
});
viewButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new ViewStudents().setVisible(true);
dispose();
}
});
panel.add(addButton);
panel.add(updateButton);
panel.add(updateButtonAll);
panel.add(deleteButton);
panel.add(viewButton);
add(panel, BorderLayout.SOUTH);
setLayout(new BorderLayout());
add(headerPanel, BorderLayout.NORTH);
add(panel, BorderLayout.CENTER);
}
public Connection getConnection() throws SQLException {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
String url = "jdbc:mysql://localhost:3306/student_db?useSSL=false&serverTimezone=UTC";
String username = "root";
String password = "root";
return DriverManager.getConnection(url, username, password);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
new StudentManagementSystemGUI().setVisible(true);
});
}
}