多个界面实现员工薪资管理系统Java代码
时间: 2023-09-27 13:10:41 浏览: 134
基于Java +Swing的员工工资管理系统.rar
5星 · 资源好评率100%
以下是基于Java Swing实现的员工薪资管理系统的示例代码:
```
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class EmployeeSalaryManagementSystem implements ActionListener {
JFrame frame;
JLabel titleLabel, nameLabel, idLabel, departmentLabel, salaryLabel;
JTextField nameTextField, idTextField, departmentTextField, salaryTextField;
JButton addButton, deleteButton, updateButton, clearButton, exitButton;
JTable table;
EmployeeSalaryManagementSystem() {
frame = new JFrame("Employee Salary Management System");
frame.setLayout(null);
frame.setSize(800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
titleLabel = new JLabel("Employee Salary Management System");
titleLabel.setBounds(250, 10, 300, 30);
titleLabel.setFont(new Font("Serif", Font.BOLD, 18));
frame.add(titleLabel);
nameLabel = new JLabel("Name:");
nameLabel.setBounds(50, 50, 100, 30);
frame.add(nameLabel);
nameTextField = new JTextField();
nameTextField.setBounds(200, 50, 200, 30);
frame.add(nameTextField);
idLabel = new JLabel("ID:");
idLabel.setBounds(50, 100, 100, 30);
frame.add(idLabel);
idTextField = new JTextField();
idTextField.setBounds(200, 100, 200, 30);
frame.add(idTextField);
departmentLabel = new JLabel("Department:");
departmentLabel.setBounds(50, 150, 100, 30);
frame.add(departmentLabel);
departmentTextField = new JTextField();
departmentTextField.setBounds(200, 150, 200, 30);
frame.add(departmentTextField);
salaryLabel = new JLabel("Salary:");
salaryLabel.setBounds(50, 200, 100, 30);
frame.add(salaryLabel);
salaryTextField = new JTextField();
salaryTextField.setBounds(200, 200, 200, 30);
frame.add(salaryTextField);
addButton = new JButton("Add");
addButton.setBounds(50, 250, 80, 30);
addButton.addActionListener(this);
frame.add(addButton);
deleteButton = new JButton("Delete");
deleteButton.setBounds(140, 250, 80, 30);
deleteButton.addActionListener(this);
frame.add(deleteButton);
updateButton = new JButton("Update");
updateButton.setBounds(230, 250, 80, 30);
updateButton.addActionListener(this);
frame.add(updateButton);
clearButton = new JButton("Clear");
clearButton.setBounds(320, 250, 80, 30);
clearButton.addActionListener(this);
frame.add(clearButton);
exitButton = new JButton("Exit");
exitButton.setBounds(410, 250, 80, 30);
exitButton.addActionListener(this);
frame.add(exitButton);
table = new JTable();
table.setBounds(50, 300, 600, 200);
frame.add(table);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == addButton) {
// 添加员工记录
} else if (e.getSource() == deleteButton) {
// 删除员工记录
} else if (e.getSource() == updateButton) {
// 更新员工记录
} else if (e.getSource() == clearButton) {
// 清空员工记录
} else if (e.getSource() == exitButton) {
// 退出系统
System.exit(0);
}
}
public static void main(String[] args) {
new EmployeeSalaryManagementSystem();
}
}
```
这个示例代码中实现了一个基本的员工薪资管理系统界面,包括添加、删除、更新、清空和退出操作。您可以根据需求进行修改和完善。
阅读全文