java学生信息管理系统ui
时间: 2023-10-14 09:04:54 浏览: 40
以下是一个简单的Java学生信息管理系统UI示例:
```java
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class StudentInfoUI extends JFrame implements ActionListener {
private JLabel nameLabel, idLabel, genderLabel, majorLabel;
private JTextField nameField, idField, majorField;
private JRadioButton maleButton, femaleButton;
private JButton addButton, deleteButton, updateButton, searchButton;
private JPanel infoPanel, buttonPanel;
public StudentInfoUI() {
// 设置窗口标题和大小
setTitle("学生信息管理系统");
setSize(400, 200);
// 创建学生信息面板
infoPanel = new JPanel(new GridLayout(4, 2));
nameLabel = new JLabel("姓名");
idLabel = new JLabel("学号");
genderLabel = new JLabel("性别");
majorLabel = new JLabel("专业");
nameField = new JTextField();
idField = new JTextField();
majorField = new JTextField();
maleButton = new JRadioButton("男");
femaleButton = new JRadioButton("女");
ButtonGroup genderGroup = new ButtonGroup();
genderGroup.add(maleButton);
genderGroup.add(femaleButton);
infoPanel.add(nameLabel);
infoPanel.add(nameField);
infoPanel.add(idLabel);
infoPanel.add(idField);
infoPanel.add(genderLabel);
infoPanel.add(maleButton);
infoPanel.add(new JLabel());
infoPanel.add(femaleButton);
infoPanel.add(majorLabel);
infoPanel.add(majorField);
// 创建按钮面板
buttonPanel = new JPanel(new FlowLayout());
addButton = new JButton("添加");
deleteButton = new JButton("删除");
updateButton = new JButton("更新");
searchButton = new JButton("查找");
addButton.addActionListener(this);
deleteButton.addActionListener(this);
updateButton.addActionListener(this);
searchButton.addActionListener(this);
buttonPanel.add(addButton);
buttonPanel.add(deleteButton);
buttonPanel.add(updateButton);
buttonPanel.add(searchButton);
// 将面板添加到窗口中
add(infoPanel, BorderLayout.CENTER);
add(buttonPanel, BorderLayout.SOUTH);
// 设置窗口可见性和关闭方式
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e) {
// 处理按钮点击事件
if (e.getSource() == addButton) {
// 添加学生信息
} else if (e.getSource() == deleteButton) {
// 删除学生信息
} else if (e.getSource() == updateButton) {
// 更新学生信息
} else if (e.getSource() == searchButton) {
// 查找学生信息
}
}
public static void main(String[] args) {
new StudentInfoUI();
}
}
```
这是一个简单的UI,包含了学生的姓名、学号、性别和专业信息,以及添加、删除、更新和查找学生信息的按钮。你可以根据自己的需求进行修改和扩展。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)