This project was deployed via Vibe Deploy and is actively served worldwide on Cloudflare Global Edge. Source assets, architecture specifications, and execution instructions are available below.
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
class Student {
private String name;
private int age;
private String course;
private String studentId;
public Student(String name, int age, String course, String studentId) {
this.name = name;
this.age = age;
this.course = course;
this.studentId = studentId;
}
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public int getAge() { return age; }
public void setAge(int age) { this.age = age; }
public String getCourse() { return course; }
public void setCourse(String course) { this.course = course; }
public String getStudentId() { return studentId; }
public void setStudentId(String studentId) { this.studentId = studentId; }
}
class StudentManagementSystem extends JFrame {
private ArrayList<Student> students = new ArrayList<>();
private JTable table;
private DefaultTableModel model;
private JTextField nameField, ageField, courseField, idField;
private JButton addButton, editButton, deleteButton, clearButton;
private boolean isEditing = false;
private static final Color BACKGROUND_COLOR = Color.WHITE;
private static final Color TEXT_COLOR = Color.BLACK;
private static final Color BUTTON_COLOR = new Color(245, 245, 245);
private static final Color BUTTON_HOVER_COLOR = new Color(230, 230, 230);
public StudentManagementSystem() {
setTitle("Student Management System");
setSize(1000, 700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout(10, 10));
getContentPane().setBackground(BACKGROUND_COLOR);
initializeComponents();
setupTable();
setupActionButtons();
setupTableListener();
setLocationRelativeTo(null);
setVisible(true);
}
private void initializeComponents() {
JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
mainPanel.setBackground(BACKGROUND_COLOR);
mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
JPanel inputPanel = new JPanel(new GridBagLayout());
inputPanel.setBackground(BACKGROUND_COLOR);
inputPanel.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createLineBorder(Color.LIGHT_GRAY),
"Student Information"
));
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 5, 5, 5);
nameField = createStyledTextField();
ageField = createStyledTextField();
courseField = createStyledTextField();
idField = createStyledTextField();
JLabel[] labels = {
createStyledLabel("Name:"),
createStyledLabel("Age:"),
createStyledLabel("Course:"),
createStyledLabel("Student ID:")
};
JTextField[] fields = {nameField, ageField, courseField, idField};
for (int i = 0; i < labels.length; i++) {
gbc.gridx = 0; gbc.gridy = i; gbc.weightx = 0.1;
inputPanel.add(labels[i], gbc);
gbc.gridx = 1; gbc.weightx = 0.9;
inputPanel.add(fields[i], gbc);
}
mainPanel.add(inputPanel, BorderLayout.NORTH);
add(mainPanel, BorderLayout.CENTER);
}
private JLabel createStyledLabel(String text) {
JLabel label = new JLabel(text);
label.setForeground(TEXT_COLOR);
label.setFont(new Font("Arial", Font.PLAIN, 14));
return label;
}
private JTextField createStyledTextField() {
JTextField field = new JTextField();
field.setPreferredSize(new Dimension(200, 30));
field.setFont(new Font("Arial", Font.PLAIN, 14));
field.setBackground(BACKGROUND_COLOR);
field.setForeground(TEXT_COLOR);
field.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(Color.LIGHT_GRAY),
BorderFactory.createEmptyBorder(5, 5, 5, 5)
));
return field;
}
private void setupTable() {