Eclipse+Java+Swing 학생 성적 관리 시스템 의 인 스 턴 스 코드 구현
이 시스템 은 사용자 로그 인 을 실 현 했 고 학생 성적 에 대한 추가 삭제 와 검 사 를 실 현 했 으 며 사용자 가 비밀 번 호 를 수정 하 는 기능 을 실 현 했 습 니 다.MD5 암호 화 알고리즘 을 사용 하고 데이터 베 이 스 는 Mysql 8.0.13 을 사용 하 며 인터페이스 가 좋 습 니 다.
2.시스템 전시
1.로그 인 페이지
2.홈 페이지
3.학생 성적 조회
4.학생 성적 수정
5.학생 성적 추가
6.시스템 비밀번호 수정
3.시스템 구현 Student.java
package com.sjsq.model;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author shuijianshiqing
*
*/
public class Student {
//
private String sId;
//
private String sName;
//
private String sSex;
//
private String sCollege;
private String sC;
private String sMath;
private String sEnglish;
private String sChinese;
private String sJava;
public Student() {
super();
}
public Student(String sId, String sName, String sSex, String sCollege, String sC, String sMath,
String sEnglish, String sChinese, String sJava) {
super();
this.sId = sId;
this.sName = sName;
this.sSex = sSex;
this.sCollege = sCollege;
this.sC = sC;
this.sMath = sMath;
this.sEnglish = sEnglish;
this.sChinese = sChinese;
this.sJava = sJava;
}
public static List<Student> students=new ArrayList<Student>();
public String getsId() {
return sId;
}
public void setsId(String sId) {
this.sId = sId;
}
public String getsName() {
return sName;
}
public void setsName(String sName) {
this.sName = sName;
}
public String getsSex() {
return sSex;
}
public void setsSex(String sSex) {
this.sSex = sSex;
}
public String getsCollege() {
return sCollege;
}
public void setsCollege(String sCollege) {
this.sCollege = sCollege;
}
public String getsC() {
return sC;
}
public void setsC(String sC) {
this.sC = sC;
}
public String getsMath() {
return sMath;
}
public void setsMath(String sMath) {
this.sMath = sMath;
}
public String getsEnglish() {
return sEnglish;
}
public void setsEnglish(String sEnglish) {
this.sEnglish = sEnglish;
}
public String getsChinese() {
return sChinese;
}
public void setsChinese(String sChinese) {
this.sChinese = sChinese;
}
public String getsJava() {
return sJava;
}
public void setsJava(String sJava) {
this.sJava = sJava;
}
@Override
public String toString() {
return "Student [sId=" + sId + ", sName=" + sName + ", sSex=" + sSex + ", sCollege=" + sCollege + ", sC="
+ sC + ", sMath=" + sMath + ", sEnglish=" + sEnglish + ", sChinese=" + sChinese + ", sJava="
+ sJava + "]";
}
}
StudentDao.java
package com.sjsq.dao;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.sjsq.model.Student;
import com.sjsq.util.DBUtil;
public class StudentDao {
public static int progress;
// private final String FILE_PATH="d:\\student.xls";
public static StudentDao getInstance() {
StudentDao studentDao;
return studentDao = new StudentDao();
}
//
public ResultSet queryAll() {
ResultSet rs = null;
String sql = "select * from Student";
System.out.println("------ ------");
System.out.println("sql :" + sql);
DBUtil db = new DBUtil();
try {
rs = db.executeQuery(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return rs;
}
// , List
public List<Student> queryAllStudent() {
List<Student> listStudent = new ArrayList<Student>();
String sql = "select * from student";
System.out.println("------ ------");
System.out.println("sql :" + sql);
DBUtil db = new DBUtil();
ResultSet rs = null;
try {
rs = db.executeQuery(sql);
while (rs.next()) {
Student studentTmp = new Student();
studentTmp.setsId(rs.getString("sId"));
studentTmp.setsName(rs.getString("sName"));
studentTmp.setsSex(rs.getString("sSex"));
studentTmp.setsCollege(rs.getString("sCollege"));
studentTmp.setsC(rs.getString("sC"));
studentTmp.setsMath(rs.getString("sMath"));
studentTmp.setsEnglish(rs.getString("sEnglish"));
studentTmp.setsChinese(rs.getString("sChinese"));
studentTmp.setsJava(rs.getString("sJava"));
listStudent.add(studentTmp);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
db.close();
}
return listStudent;
}
public static int getprogress() {
return progress;
}
//
public ResultSet queryByCondition(String[] data) {
ResultSet rs = null;
String sql = "select * from student where 1=1";
int i = 0;
//
if (!(data[0].equals(""))) {
sql += " and sid='" + data[0] + "' ";
}
//
if (!(data[1].equals(""))) {
sql += " and sname='" + data[1] + "' ";
}
//
if (!(data[2].equals(""))) {
sql += " and senglish='" + data[2] + "' ";
}
//
if (!(data[3].equals(""))) {
sql += " and ssex='" + data[3] + "' ";
}
System.out.println("------ ------");
System.out.println("sql :" + sql);
DBUtil db = new DBUtil();
try {
rs = db.executeQuery(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return rs;
}
// ,
public boolean insertStudentInformation(Student student) {
DBUtil DBUtil = new DBUtil();
// student sid
String sid = student.getsId();
String sname = student.getsName();
String ssex = student.getsSex();
String scollege = student.getsCollege();
String sc = student.getsC();
String smath = student.getsMath();
String senglish = student.getsEnglish();
String schinese = student.getsChinese();
String sjava = student.getsJava();
String sql = "insert into student(sid,sname,ssex,scollege,sc,smath,senglish,schinese,sjava)" +
"values('" + sid + "','" + sname + "','" + ssex + "','" + scollege+ "','" + sc+ "','"
+ smath + "','" + senglish + "','" + schinese + "','" + sjava + "')";
System.out.println("------ ------");
System.out.println("sql :" + sql);
//
// boolean ,
boolean flag = false;
try {
//
flag = DBUtil.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
DBUtil.close();
//
return flag;
}
//
public int queryForsidinformation(String sid) {
DBUtil db = new DBUtil();
// sid sid
String sql = "select * from student where sid=" + sid;
System.out.println("------ ------");
System.out.println("sql :" + sql);
ResultSet rs = null;
int count = 0;
try {
//
rs = (ResultSet) db.executeQuery(sql);
// count++
if (rs.next()) {
count++;
}
} catch (SQLException e) {
e.printStackTrace();
}
//
db.close();
// count
return count;
}
// ,
public boolean updateStudentInformation(Student student) {
DBUtil DBUtil = new DBUtil();
// scollege,sc,smath,senglish,schinese,sjava
String sql = "update student set sname=" + "'" + student.getsName() + "'" + " ,"
+ " ssex=" + "'" + student.getsSex() + "'" + " ,"
+ " scollege=" + "'" + student.getsCollege() + "' " + " ,"
+ " sc=" + "'" + student.getsC() + "' " + " ,"
+ " smath=" + "'" + student.getsMath() + "' " + " ,"
+ " senglish=" + "'" + student.getsEnglish() + "'" + ","
+ " schinese=" + "'" + student.getsChinese() + "'" + " ,"
+ " sjava=" + "'" + student.getsJava()+ "'"
+ " where" + " sid=" + "'"+ student.getsId() + "'";
System.out.println("------ ------");
System.out.println("sql :" + sql);
boolean flag = false;
try {
flag = DBUtil.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return flag;
}
//
public boolean deleteStudentInfoBySid(String sid) {
boolean flag = false;
String sql = "delete from student where sid=" + "'" + sid + "'";
System.out.println("------ ------");
System.out.println("sql :" + sql);
DBUtil DBUtil = new DBUtil();
try {
flag = DBUtil.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return flag;
}
}
LoginFrame.java
package com.sjsq.view;
import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.Timer;
import javax.swing.UIManager;
import com.sjsq.model.User;
import com.sjsq.util.MD5Util;
import com.sjsq.dao.UserDao;
public class LoginFrame extends JFrame implements ActionListener {
public static String uname = null;
public static String pwd = null;
String username, password, login, quit;
//
private JLabel loginJLabel;
private JPanel jContentPane = null;
private JButton jButtonLogin = null;
private JButton jButtonExit = null;
private JTextField jTextFieldUserName = null;
private JTextField jTextFieldPassWord = null;
//
static int storeUserId;
//
public JLabel jLabel_Image = null;
//
public static String storeUserame = null;
//
public static String storeUserPassword = null;
//
static boolean RELOAD = true;
private JLabel jLabelUserName = null;
private JLabel jLabelPassWord = null;
int index;
public LoginFrame() {
//
setForeground(new Color(255, 255, 255));
this.setResizable(false);
this.setSize(800, 500);
this.setTitle(" ");
this.setLocationRelativeTo(null);
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");// windows
} catch (Exception e) {
e.printStackTrace();
}
loginJLabel = new JLabel(" ");
Font font = new Font(" ",Font.BOLD,40);
loginJLabel.setFont(font);
loginJLabel.setBounds(220,100,650, 50);
loginJLabel.setForeground(Color.DARK_GRAY);
getContentPane().add(loginJLabel);
Font font2 = new Font(" ",Font.BOLD,15);
jLabelPassWord = new JLabel();
jLabelPassWord.setFont(font2);
jLabelPassWord.setBounds(new Rectangle(300, 250, 71, 29));
jLabelPassWord.setText(" :");
jLabelUserName = new JLabel();
jLabelUserName.setBounds(new Rectangle(300, 300, 71, 29));
jLabelUserName.setFont(font2);
jLabelUserName.setText(" :");
//
jTextFieldUserName = new JTextField(20);
jTextFieldUserName.setBounds(new Rectangle(360, 250, 154, 33));
//
jTextFieldPassWord = new JPasswordField();
jTextFieldPassWord.setBounds(new Rectangle(360, 300, 154, 33));
//
jButtonLogin = new JButton();
jButtonLogin.setBounds(new Rectangle(320, 380, 78, 26));
jButtonLogin.setText(" ");
jButtonLogin.setUI(new BEButtonUI()
.setNormalColor(BEButtonUI.NormalColor.green));
//
getRootPane().setDefaultButton(jButtonLogin);
//
jButtonExit = new JButton();
jButtonExit.setUI(new BEButtonUI()
.setNormalColor(BEButtonUI.NormalColor.lightBlue));
jButtonExit.setBounds(new Rectangle(420, 380, 78, 26));
jButtonExit.setText(" ");
//
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabelUserName, null);
jContentPane.add(jLabelPassWord, null);
jContentPane.add(jButtonLogin, null);
jContentPane.add(jButtonExit, null);
jContentPane.add(jTextFieldUserName, null);
jContentPane.add(jTextFieldPassWord, null);
getContentPane().add(jContentPane);
jTextFieldUserName.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyTyped(KeyEvent e) {
if(e.getKeyChar() == KeyEvent.VK_ENTER){
jTextFieldPassWord.requestFocus();
}
}
});
jTextFieldPassWord.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if(e.getKeyChar() == KeyEvent.VK_ENTER){
username = jTextFieldUserName.getText();
password = MD5Util.string2MD5(jTextFieldPassWord.getText());
User user = new User();
user.setUsername(username);
user.setPassword(password);
String s=user.getUsername();
String p=jTextFieldPassWord.getText();
UserDao userDao = new UserDao();
int choice = 0;
if(!userDao.checkUser(user)) {
JOptionPane.showMessageDialog(null, " "," ",JOptionPane.WARNING_MESSAGE);
}else {
setVisible(false);
MainMenuFrame MM = new MainMenuFrame();
uname = s;
pwd=p;
}
}
}
});
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
//
jTextFieldUserName.addActionListener(this);
jTextFieldPassWord.addActionListener(this);
jButtonLogin.addActionListener(this);
jButtonExit.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
//
username = jTextFieldUserName.getText();
password = MD5Util.string2MD5(jTextFieldPassWord.getText());
User user = new User();
user.setUsername(username);
user.setPassword(password);
String s = user.getUsername();
String p = jTextFieldPassWord.getText();
UserDao userDao = new UserDao();
int choice = 0;
if (e.getSource() == jButtonLogin) {
if (!userDao.checkUser(user)) {
JOptionPane.showMessageDialog(null, " ", " ", JOptionPane.WARNING_MESSAGE);
} else {
setVisible(false);
MainMenuFrame MM = new MainMenuFrame();
uname = s;
pwd = p;
}
} else if (e.getSource() == jButtonExit) {
System.exit(0);
}
}
//
public static void main(String[] args) {
new LoginFrame();
}
}
MainMenuFrame.java
package com.sjsq.view;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI;
/*
*
*/
public class MainMenuFrame extends JFrame implements ActionListener {
private JFrame mainmenu;
private JTextArea text;
// ( )
private JMenuBar menuBar1;
private JMenuItem aboutSystem;
public MainMenuFrame() {
mainmenu();
}
public void mainmenu() {
mainmenu = new JFrame(" ");
setLocationRelativeTo(null);//
mainmenu.setSize(850, 650);
mainmenu.getContentPane().add(new JScrollPane(text));
JPanel jContentPane = new JPanel();
jContentPane.setLayout(null);
//
JButton jButtonSelect = new JButton();
jButtonSelect.setBounds(new Rectangle(320, 100, 100, 52));
jButtonSelect.setText(" ");
jButtonSelect.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.lightBlue));
getRootPane().setDefaultButton(jButtonSelect);//
//
JButton jButtonAdd = new JButton();
jButtonAdd.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.lightBlue));
jButtonAdd.setBounds(new Rectangle(320, 200, 100, 52));
jButtonAdd.setText(" ");
//
JButton jButtonAlterPwd = new JButton();
jButtonAlterPwd.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.lightBlue));
jButtonAlterPwd.setBounds(new Rectangle(320, 300, 100, 52));
jButtonAlterPwd.setText(" ");
//
JButton jButtonExit = new JButton();
jButtonExit.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.lightBlue));
jButtonExit.setBounds(new Rectangle(320, 400, 100, 52));
jButtonExit.setText(" ");
jContentPane.add(jButtonSelect, null);
jContentPane.add(jButtonAdd, null);
jContentPane.add(jButtonAlterPwd, null);
jContentPane.add(jButtonExit, null);
// Label Frame
mainmenu.getContentPane().add(jContentPane);
//
Font font = new Font(" ", Font.BOLD, 16);
//
menuBar1 = new JMenuBar();
// aboutSystem = new JMenuItem(" ",new
// ImageIcon("src/images/icons/about.png"));
aboutSystem = new JMenuItem(" ");
aboutSystem.setMnemonic('H');
menuBar1.add(aboutSystem);
//
jButtonSelect.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("------ -----");
QueryStudentInfo queryStudentInfo = new QueryStudentInfo();
}
});
//
jButtonAdd.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("------ -----");
AddStudentInfo addStudentInfo = new AddStudentInfo();
}
});
//
jButtonAlterPwd.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("------ -----");
ModifyPasswordInfo modifyPasswordInfo = new ModifyPasswordInfo();
}
});
//
jButtonExit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("------ -----");
System.exit(1);
}
});
//
aboutSystem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("------ ------");
AboutSystem aboutSystem = new AboutSystem();
}
});
//
mainmenu.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent arg0) {
System.exit(1);
}
});
mainmenu.setJMenuBar(menuBar1);
mainmenu.setVisible(true);
// mainmenu.setLocation(250, 50);
mainmenu.setLocationRelativeTo(null);
aboutSystem.addActionListener(this);
}
//
public static void main(String[] args) {
new MainMenuFrame();
}
@Override
public void actionPerformed(ActionEvent arg0) {
}
}
Eclipse+Java+Swing 의 학생 성적 관리 시스템 구현 에 관 한 이 글 은 여기까지 소개 되 었 습 니 다.더 많은 Eclipse+Java+Swing 의 학생 성적 관리 시스템 구현 에 관 한 내용 은 우리 의 이전 글 을 검색 하거나 아래 의 관련 글 을 계속 조회 하 시기 바 랍 니 다.앞으로 도 많은 관심 부탁드립니다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
자바를 잡아버려 (1)나의 생각을 적고 복습을 해버릴 것 이다 책을 펼치자 마자 나오는 설명인데 그 안의 내용을 실행하게 된다 라고 설명을 해준다 아래 소스코드와 실행 결과로 위에 설명을 보충해준다 사칙연산과 나머지를 계산하는 것 비교연...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.