Java课程设计:基于Java+Swing+MySQL的图书管理系统(内附源码)

一、项目介绍

图书管理系统是一个常见的软件项目,广泛应用于图书馆、学校、企业等需要管理图书资源的场景。该系统通常涵盖图书信息录入、查询、借阅、归还等核心功能,是实现图书资源高效管理的重要工具。

随着信息技术的快速发展,传统纸质图书管理方式已经难以满足现代化管理的需求。图书管理系统的数字化转型成为当前图书馆和相关行业的重要发展方向。通过开发和应用图书管理系统,可以实现图书资源的数字化管理,提高工作效率,增强用户体验。

二、项目展示

登录界面
在这里插入图片描述

首页
请添加图片描述
读者查询
在这里插入图片描述
借阅图书
在这里插入图片描述
图书查询
在这里插入图片描述

三、源码展示

登录界面实现

public class LoginForm extends JFrame {
   


    private JComboBox comboBox;
    private JLabel title,usernamelab,passwordlab,select;
    private JTextField usernameField;
    private JPasswordField passwordField;
    private JButton submit,updatePwd,regist;
    private UserService service = new UserService();

    public LoginForm() {
   

        Container container = getContentPane();
        container.setLayout(null);


        submit=new JButton("登录");
        submit.setBounds(20,210,60,20);
        //登录监听
        submit.addActionListener(new ActionListener() {
   
            @Override
            public void actionPerformed(ActionEvent e) {
   
                loginByUserAndPwd(e);
            }
        });
        regist=new JButton("注册");
        regist.setBounds(90,210,60,20);
        //跳转到注册界面
        regist.addActionListener(new ActionListener() {
   
            @Override
            public void actionPerformed(ActionEvent e) {
   
                new RegistForm();
            }
        });

        updatePwd=new JButton("修改密码");
        updatePwd.setBounds(160,210,100,20);
        //更新密码
        updatePwd.addActionListener(new ActionListener() {
   
            @Override
            public void actionPerformed(ActionEvent e) {
   
                new UpdatePwdForm();
            }
        });


        title=new JLabel("图书管理系统");
        title.setFont(new Font("宋体", Font.PLAIN, 24));
        title.setBounds(70,30,200,25);
        usernamelab=new JLabel("用户名:");
        usernamelab.setFont(new Font("宋体", Font.PLAIN, 16));
        usernamelab.setBounds(50,80,60,20);
        passwordlab=new JLabel("密码:");
        passwordlab.setFont(new Font("宋体", Font.PLAIN, 16));
        passwordlab.setBounds(50,120,60,20);

        usernameField=new JTextField();
        usernameField.setBounds(120,80,130,20);
        passwordField=new JPasswordField();
        passwordField.setEchoChar('*');
        passwordField.setBounds(120,120,130,20);


        container.add(title);
        container.add(usernamelab);container.add(usernameField);
        container.add(passwordlab);container.add(passwordField);
        container.add(submit);container.add(regist);container.add(updatePwd);


        //container.setBackground(Color.RED);
        setTitle("登录");
        setSize(300,300);
        setLocationRelativeTo(null);
        setResizable(false);
        setVisible(true);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    private void loginByUserAndPwd(ActionEvent e) {
   
        String username = this.usernameField.getText();
        String password = new String(this.passwordField.getPassword());
        String is_admin="";

        if(StringUtil.isEmpty(username)||StringUtil.isEmpty(password)){
   
            JOptionPane.showMessageDialog(null,"用户名或密码不能为空");
        }else {
   
                is_admin="1";//管理员
                User user = service.login(username, password, is_admin);
                if (user!=null){
   
                    JOptionPane.showMessageDialog(null,"登录成功");
                    dispose();
                    new RootMainForm();
                }else {
   
                    JOptionPane.showMessageDialog(null,"账号或面错误");
                }
            }
        }

    }

添加图书界面实现

public class AddBookForm extends JFrame {
   

    private JLabel bookId,bookName,bookType,translator,publishTime,stock,price,publisher,author;
    private JTextField bookIdField,bookNameField,translatorField,stockField,priceField,publisherField,authorField;
    private JButton btn_Add,btn_Cancel;
    private  JComboBox<String> comboBox;
    final JXDatePicker datepick = new JXDatePicker();
     

    public AddBookForm(){
   
        Container container = getContentPane();
        container.setLayout(null);

        btn_Add=new JButton("保存");
        btn_Add.setBounds(190,310,80,20);
        btn_Cancel=new JButton("取消");
        btn_Cancel.setBounds(320,310,80,20);
        //取消按钮监听
        btn_Cancel.addActionListener(new ActionListener() {
   
            @Override
            public void actionPerformed(ActionEvent e) {
   
                dispose();
            }
        });
        //添加按钮监听
        btn_Add.addActionListener(new ActionListener() {
   
            @Override
            public void actionPerformed(ActionEvent e) {
   
                try {
   
                    addBook(e);
                } catch (Exception ex) {
   
                    ex.printStackTrace();
                }
            }
        });

        bookId=new JLabel("图书编号");
        bookId.setFont(new Font
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值