java + mysql 学生管理系统

期末项目总结,主要是从网上借鉴学习和自身结合
摘要由CSDN通过智能技术生成

分为三个模块:登录模块,主页面模块,信息存储模块

1.首先写出登录页面  代码:

package stu;
 
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
 
class LoginCheck{
    private String name;
    private String password;
    public LoginCheck(String name,String password){
        this.name=name;
        this.password=password;
    }
    public boolean equals(){
        if("root".equals(name)&&"123456".equals(password)){
            return true;
        }else{
            return false;
        }
    }
};
class ActionHandle{
    private JFrame frame=new JFrame("学生信息管理系统");
    private JTextField name=new JTextField();//设置文本框
    private JPasswordField pass=new JPasswordField();
    private JLabel but1=new JLabel("用户名:");
    private JLabel but2=new JLabel("密   码:");
    private JButton but3=new JButton("登录");
    private JButton but4=new JButton("重置");
 
    public ActionHandle(){
        but3.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                if(e.getSource()==but3){
                    String sname=name.getText();
                    String spass=new String(pass.getPassword());
                    LoginCheck log=new LoginCheck(sname,spass);
                    if(log.equals()){
                        try {
                            new Menu();
                        } catch (Exception e1) {
 
                            e1.printStackTrace();
                        }
                        frame.setVisible(false);
 
                    }else{
                        JOptionPane.showMessageDialog(null, "登录失败,错误的用户名或密码!");
                    }
                }
            }
        });
        but4.addActionListener(
                new ActionListener(){
                    public void actionPerformed(ActionEvent e){
                        if(e.getSource()==but4){
                            name.setText("");
                            pass.setText("");
                        }
                    }
 
                });
        frame.setLayout(null);
        but1.setBounds(80, 40 , 80,30);
        name.setBounds(140,42, 120, 25);    //
        but2.setBounds(80, 80 , 80,30);
        pass.setBounds(140,82, 120, 25);
        but3.setBounds(130, 150 , 60,30);
        but4.setBounds(210, 150 , 60,30);
        frame.setSize(400,330);
        frame.setLocation(300, 200);
        frame.add(but1);
        frame.add(name);
        frame.add(pass);
        frame.add(but2);
        frame.add(but3);
        frame.add(but4);
        frame.setVisible(true);
    }
}
class  Enter{
    public static void main(String[] args) {
 
        new ActionHandle();
    }
 
}
 

2.写出主界面模块  代码:

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
public class Menu {
    private JButton but1 = new JButton("增加数据"); // 按钮
    private JButton but2 = new JButton("删除数据");
    private JButton but3 = new JButton("修改数据");
    private JButton but4 = new JButton("

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值