学生信息管理系统界面Java代码
时间: 2023-09-08 10:09:21 浏览: 72
以下是一个简单的学生信息管理系统的界面Java代码示例:
```java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class StudentManagementSystem extends JFrame implements ActionListener {
JLabel l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13;
JTextField tf1, tf2, tf3, tf4, tf5, tf6, tf7, tf8, tf9, tf10, tf11, tf12, tf13;
JButton btn1, btn2, btn3, btn4, btn5;
StudentManagementSystem() {
setTitle("学生信息管理系统");
setSize(700, 550);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setLayout(null);
l1 = new JLabel("学号:");
l1.setBounds(50, 50, 100, 20);
panel.add(l1);
tf1 = new JTextField();
tf1.setBounds(160, 50, 150, 20);
panel.add(tf1);
l2 = new JLabel("姓名:");
l2.setBounds(50, 80, 100, 20);
panel.add(l2);
tf2 = new JTextField();
tf2.setBounds(160, 80, 150, 20);
panel.add(tf2);
l3 = new JLabel("性别:");
l3.setBounds(50, 110, 100, 20);
panel.add(l3);
tf3 = new JTextField();
tf3.setBounds(160, 110, 150, 20);
panel.add(tf3);
l4 = new JLabel("年龄:");
l4.setBounds(50, 140, 100, 20);
panel.add(l4);
tf4 = new JTextField();
tf4.setBounds(160, 140, 150, 20);
panel.add(tf4);
l5 = new JLabel("出生日期:");
l5.setBounds(50, 170, 100, 20);
panel.add(l5);
tf5 = new JTextField();
tf5.setBounds(160, 170, 150, 20);
panel.add(tf5);
l6 = new JLabel("班级:");
l6.setBounds(50, 200, 100, 20);
panel.add(l6);
tf6 = new JTextField();
tf6.setBounds(160, 200, 150, 20);
panel.add(tf6);
l7 = new JLabel("电话号码:");
l7.setBounds(50, 230, 100, 20);
panel.add(l7);
tf7 = new JTextField();
tf7.setBounds(160, 230, 150, 20);
panel.add(tf7);
btn1 = new JButton("添加");
btn1.setBounds(50, 290, 80, 20);
btn1.addActionListener(this);
panel.add(btn1);
btn2 = new JButton("删除");
btn2.setBounds(140, 290, 80, 20);
btn2.addActionListener(this);
panel.add(btn2);
btn3 = new JButton("修改");
btn3.setBounds(230, 290, 80, 20);
btn3.addActionListener(this);
panel.add(btn3);
btn4 = new JButton("查询");
btn4.setBounds(320, 290, 80, 20);
btn4.addActionListener(this);
panel.add(btn4);
btn5 = new JButton("清空");
btn5.setBounds(410, 290, 80, 20);
btn5.addActionListener(this);
panel.add(btn5);
l8 = new JLabel("学生信息管理系统");
l8.setBounds(50, 350, 300, 30);
l8.setFont(new Font("宋体", Font.BOLD, 24));
panel.add(l8);
l9 = new JLabel("学号");
l9.setBounds(50, 400, 100, 20);
panel.add(l9);
tf8 = new JTextField();
tf8.setBounds(100, 400, 150, 20);
panel.add(tf8);
l10 = new JLabel("姓名");
l10.setBounds(50, 430, 100, 20);
panel.add(l10);
tf9 = new JTextField();
tf9.setBounds(100, 430, 150, 20);
panel.add(tf9);
l11 = new JLabel("性别");
l11.setBounds(50, 460, 100, 20);
panel.add(l11);
tf10 = new JTextField();
tf10.setBounds(100, 460, 150, 20);
panel.add(tf10);
l12 = new JLabel("年龄");
l12.setBounds(300, 400, 100, 20);
panel.add(l12);
tf11 = new JTextField();
tf11.setBounds(350, 400, 150, 20);
panel.add(tf11);
l13 = new JLabel("出生日期");
l13.setBounds(300, 430, 100, 20);
panel.add(l13);
tf12 = new JTextField();
tf12.setBounds(350, 430, 150, 20);
panel.add(tf12);
JLabel l14 = new JLabel("班级");
l14.setBounds(300, 460, 100, 20);
panel.add(l14);
tf13 = new JTextField();
tf13.setBounds(350, 460, 150, 20);
panel.add(tf13);
setVisible(true);
add(panel);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btn1) {
// 添加按钮被点击
// 将文本框中的内容添加到数据库中
} else if (e.getSource() == btn2) {
// 删除按钮被点击
// 从数据库中删除指定的学生信息
} else if (e.getSource() == btn3) {
// 修改按钮被点击
// 将文本框中的内容更新到数据库中
} else if (e.getSource() == btn4) {
// 查询按钮被点击
// 显示指定学号的学生信息
} else if (e.getSource() == btn5) {
// 清空按钮被点击
// 清空文本框中的内容
tf1.setText("");
tf2.setText("");
tf3.setText("");
tf4.setText("");
tf5.setText("");
tf6.setText("");
tf7.setText("");
tf8.setText("");
tf9.setText("");
tf10.setText("");
tf11.setText("");
tf12.setText("");
tf13.setText("");
}
}
public static void main(String[] args) {
new StudentManagementSystem();
}
}
```
注意:这只是一个简单的示例,实际的学生信息管理系统可能会更加复杂,需要根据具体的需求进行设计和实现。
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)