java student management system (interface version)

Run shot

 

 

 

project instruction:

      The system interface is designed to be a simple on my own, and had intended to use windowbuilder plug-in design, lead to code redundancy, can affect the readability of the code, it may be conceivable to use windowbuilder after unfriendly white plug. Although simple interface design, but I will try to think of the function to write the whole, of course, to the page you can add your own design, such as adding a background image, etc., have online guide for the interface from simple aesthetics.

Key Code:

package student.view;

import java.awt.*;
import javax.swing.*;

import student.dao.StuDao;
import student.model.Student;

import java.util.*;
/**
 * 查询列表类
 *
 */
public class ListFrame extends JFrame {
	JButton buttonreturn = new JButton("返回");
	JTable jtable;
	JScrollPane jscrollpane = new JScrollPane();

	Vector columnNames = null;
	Vector rowData = null;

	public ListFrame() {
		ArrayList<Student> students = new StuDao().listStu();
		JPanel jpforbutton = new JPanel();

		columnNames = new Vector();
		columnNames.add("学号");
		columnNames.add("姓名");
		columnNames.add("性别");
		columnNames.add("出生日期");
		rowData = new Vector();
		jpforbutton.add(buttonreturn); 
		for (int i = 0; i < students.size(); i++) {
			Vector hang = new Vector();
			hang.add(students.get(i).getNumber());
			hang.add(students.get(i).getName());
			hang.add(students.get(i).getSex());
			hang.add(students.get(i).getBirthday());
			rowData.add(hang);
		}

		jtable = new JTable(rowData, columnNames);
		jscrollpane = new JScrollPane(jtable);

		this.setLayout(new FlowLayout());
		this.add(jscrollpane);
		this.add(jpforbutton);
		// 窗口标题
		this.setTitle("学生系统-学生列表");
		// 窗体大小
		this.setSize(500, 340);
		// 设置图标
		this.setIconImage((new ImageIcon("images/logo.jpg")).getImage());
		// 设置可关闭进程
		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		// 获得屏幕宽度
		int width = Toolkit.getDefaultToolkit().getScreenSize().width;
		// 获得屏幕高度
		int height = Toolkit.getDefaultToolkit().getScreenSize().height;
		// 居中显示
		this.setLocation((width - 500) / 2, (height - 400) / 2);
		// 设置窗体可见
		this.setVisible(true);
		// 可改变窗体大小
		this.setResizable(false);

	}

}

database

DROP TABLE IF EXISTS `student`;
CREATE TABLE `student` (
  `number` varchar(20) NOT NULL,
  `name` varchar(10) DEFAULT NULL,
  `sex` varchar(10) DEFAULT NULL,
  `birthday` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of student
-- ----------------------------
INSERT INTO `student` VALUES ('12345', '12345', '12345', '12345');
INSERT INTO `student` VALUES ('123456', '男', '李四', '2020-12-12');
INSERT INTO `student` VALUES ('324423', '男', '士大夫', '2020-12-12');
INSERT INTO `student` VALUES ('45372', '男', '离得近', '2020-12-12');

Source Access:

Was going on github, given the many small partners will not use github, lay in my public personal number, number of public attention java One reply "student" to

How to run:

1. Under the first operating environment now, java + eclipse + mysql, java environment so first of all must have a local installation of the mysql database, the database on the graphical interface tool I use is navicat;

2. Create a database db_stu, there db_stu.sql get the code file in the file, Notepad to open the copy you just created to get db_stu database query can be run directly

3. Open the eclipse

Click Run

friendly reminder

Project is mainly used to practice java object-oriented thinking, as to swing in java programming knowledge, which is the programming interface is recommended not to spend too much time landscaping design, there is no need, the market rarely use java Swing to compile cs software.

There are questions you can contact the public java No. One

 

 

Published 260 original articles · won praise 112 · views 260 000 +

Guess you like

Origin blog.csdn.net/qq_34491508/article/details/103712974