<1>支持班级学生的添加删除修改储存
<2>查询支持模糊查询
<3>支持饼状图的数据可视化
效果如下:
班级
主界面源码
package student.view;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;
import student.model.Classbjtu;
import student.model.Student;
//学生管理系统的主界面
public class Mainframe extends Jframe {
//定义学生五个按钮
public JButton addBtn;//添加学生
public JButton updateBtn;//修改学生
public JButton findBtn;//查找学生
public JButton delBtn;//删除学生
public JButton listBtn;//学生列表
public JButton drawfromage; //分析年龄
public JButton drawfromhome;//分析籍贯
//定义班级按钮
public JButton addClassBtn;//添加班级
public JButton updateClassBtn;//修改班级
public JButton findClassBtn;//查找班级
public JButton delClassBtn;//删除班级
public JButton listClassBtn;//班级列表
//定义一个就是储存学生的集合Student
public static ArrayList students = new ArrayList();
//定义一个就是储存班级的集合Class
public static ArrayList classbjtu = new ArrayList();
public Mainframe() {
//给这几个学生按钮初始化
addBtn = new JButton("添加学生");
updateBtn = new JButton("修改学生");
findBtn = new JButton("查询学生");
delBtn = new JButton("删除学生");
listBtn = new JButton("学生列表");
drawfromage = new JButton("学生年龄组成");
drawfromhome = new JButton("学生籍贯组成");
//给班级按钮初始化
addClassBtn = new JButton("添加班级");
updateClassBtn = new JButton("修改班级");
findClassBtn = new JButton("查找班级");
listClassBtn = new JButton("班级列表");
delClassBtn = new JButton("删除班级");
//创建一个就是放按钮的面板
JPanel panel1 = new JPanel(new FlowLayout());
JPanel panel2 = new JPanel(new FlowLayout());
JSplitPane jSplitPane =new JSplitPane();
jSplitPane.setOneTouchExpandable(true);//让分割线显示出箭头
jSplitPane.setContinuousLayout(true);//操作箭头,重绘图形
jSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);//设置分割线方向
panel1.setSize(500, 200);
panel2.setSize(500, 200);
jSplitPane.setLeftComponent(panel1);//布局中添加组件 ,面板1
jSplitPane.setRightComponent(panel2);//添加面板2
jSplitPane.setDividerSize(10);//设置分割线的宽度
jSplitPane.setDividerLocation(474);//设定分割线的距离左边的位置
setContentPane(jSplitPane);
//学生按钮
panel1.add(addBtn);
panel1.add(updateBtn);
panel1.add(findBtn);
panel1.add(delBtn);
panel1.add(listBtn);
panel1.add(drawfromage);
panel1.add(drawfromhome);
//班级按钮
panel2.add(addClassBtn);
panel2.add(updateClassBtn);
panel2.add(delClassBtn);
panel2.add(findClassBtn);
panel2.add(listClassBtn);
//设置一张照片
ImageIcon pic1 = new ImageIcon("images/2.jpg");
JLabel jlabel1 = new JLabel(pic1);
panel1.add(jlabel1, BorderLayout.CENTER);
ImageIcon pic2 = new ImageIcon("images/1.jpg");
JLabel jlabel2 = new JLabel(pic2);
panel2.add(jlabel2, BorderLayout.CENTER);
//this.setLayout(new BorderLayout());
//this.add(panel, BorderLayout.CENTER);
//***********有关学生按钮的监听器************
//学生添加按钮的监听器
addBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mainframe.this.dispose();//主界面消失
Addframe add = new Addframe();//跳到添加学生的界面
}
});
//学生修改按钮的监听器
updateBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mainframe.this.dispose();//主界面消失
Updateframe uf = new Updateframe();//跳到修改学生的界面
}
});
//查询学生按钮的监听器
findBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mainframe.this.dispose();//主界面消失
Findframe fd = new Findframe();//跳到查询学生的界面
}
});
//学生删除按钮的监听器
delBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mainframe.this.dispose();//主界面消失
Delframe df = new Delframe();//跳到删除学生的界面
}
});
//学生列表按钮的监听器
listBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Listframe lf = new Listframe(students);//跳到列表学生的界面
}
});
drawfromage.addActionListener((new ActionListener() {
public void actionPerformed(ActionEvent e) {
Drawframe dw =new Drawframe("学生年龄组成");
}
}));
drawfromhome.addActionListener((new ActionListener() {
public void actionPerformed(ActionEvent e) {
Drawframe dw =new Drawframe("学生籍贯分析");
}
}));
//***********有关班级按钮的监听器***************
listClassBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ListClassframe lcf = new ListClassframe();//跳到列表班级的界面
}
});
delClassBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mainframe.this.dispose();//主界面消失
DelClassframe dcf = new DelClassframe();//跳到删除班级的界面
}
});
addClassBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mainframe.this.dispose();//主界面消失
AddClassframe acf = new AddClassframe();//跳到添加班级的界面
}
});
updateClassBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mainframe.this.dispose();//主界面消失
UpdateClassframe ucf = new UpdateClassframe();//跳到修改班级的界面
}
});
findClassBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mainframe.this.dispose();//主界面消失
FindClassframe fcf = new FindClassframe();//跳到查询班级的界面
}
});
//给窗口取个名字
this.setTitle("学生信息管理mis");
//给窗口设置大小
this.setSize(500, 400);
//叉号设置
this.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
//获得屏幕的宽度
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
//获得屏幕的高度
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
//居中
this.setLocation((width - 448) / 2, (height - 255) / 2);
//可见
this.setVisible(true);
//大小可变
this.setResizable(false);
}
}
纯手工撸的没有借助插件,要是那位同学需要的话.评论留言,我私信发给你.谢谢了点个赞吧.



