Java Swing图书管理系统,功能完善,直接使用 窗体版本-019

今天为大家分享一个java语言编写的图书管理程序-019,目前系统功能已经很全面,后续会进一步完善。整个系统界面漂亮,有完整得源码,希望大家可以喜欢。喜欢的帮忙点赞和关注。一起编程、一起进步

开发环境

开发语言为Java,开发环境Eclipse或者IDEA都可以,数据为MySQL。运行主程序,或者执行打开JAR文件即可以运行本程序。

系统框架

利用JDK自带的SWING框架开发。纯窗体模式,直接运行Main文件即可以。同时带有详细得设计文档。

主要功能

项目背景

随着社会的进步,信息技术的广泛应用,数字管理的优势日趋显著。针对中小型图书馆或图书室管理落后的情况,设计实现一个图书信息管理系统,通过与计算机的结合使用对中小型图书馆或图书室的各种图书信息进行管理可以给管理员和用户带来以下不同的方便:检索迅速、查找方便、可靠性高、存储量大、保密性好、寿命长、成本低等。这些优点能够极大地提高工作效率,也是图书馆等部门管理科学化、正规化的重要标志之一。而且计算机管理的成本不断降低。因此,开发一这样的中小型图书管理软件已经很有必要,并且实现研究服务于实践的原则。随着社会经济的迅速发展和科学技术的全面进步,计算机事业的飞速发展,以计算机与通信技术为基础的信息系统正处于蓬勃发展的时期。我国的学校的图书管理也正在逐步与国际接轨。图书管理环节、图书管理方式以及管理的理念都在发生深刻的变化,图书管理工作当然也在变化,因此就要求图书管理工作者学会和掌握计算机应用技术,实现图书管理工作信息化管理,因此很有必须开发一个基于窗体的的图书管理系统。

主要功能

java语言编写的图书管理程序-019:主要功能如下:

  1. 主要是查看库存图书和借阅情况

  1. 借阅图书

  1. 归还图书

  1. 修改密码

  1. 可以对所有图书进行管理以及对图书进行包括添加、删除、修改的管理

  1. 对用户进行增删改查

7对图书分类进行增删改查

运行效果

关键代码

/*
 * Login.java
 *
 * Created on __DATE__, __TIME__
 */

package com.agen.library.window;

import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import com.agen.library.factory.DAOFactory;
import com.agen.library.util.GlobalUser;
import com.agen.library.vo.User;


public class Login extends javax.swing.JFrame {

    private static final long serialVersionUID = -2176093732040600809L;

    public Login() {
        super("Library Manager System");
        Image ime = Toolkit.getDefaultToolkit().getImage(
                getClass().getResource("/images/ico.png"));
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        setIconImage(ime);
        initComponents();
        setLocationRelativeTo(null);
        this.setResizable(false);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // GEN-BEGIN:initComponents
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jPasswordField1 = new javax.swing.JPasswordField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }

            public void keyTyped(java.awt.event.KeyEvent evt) {
                formKeyTyped(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("微软雅黑", 0, 14));
        jLabel2.setText("\u7528\u6237\u540d\uff1a");

        jLabel3.setFont(new java.awt.Font("微软雅黑", 0, 14));
        jLabel3.setText("\u5bc6   \u7801\uff1a");

        jTextField1.setFont(new java.awt.Font("微软雅黑", 0, 14));
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jPasswordField1.setFont(new java.awt.Font("微软雅黑", 0, 12));
        jPasswordField1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jPasswordField1KeyTyped(evt);
            }
        });

        jButton1.setBackground(new java.awt.Color(223, 216, 216));
        jButton1.setFont(new java.awt.Font("微软雅黑", 0, 14));
        jButton1.setText("\u767b\u9646");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setBackground(new java.awt.Color(223, 216, 216));
        jButton2.setFont(new java.awt.Font("微软雅黑", 0, 14));
        jButton2.setText("\u53d6\u6d88");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel1.setIcon(new javax.swing.ImageIcon(
                getClass().getResource("/images/login_main.jpg"))); // NOI18N

        jMenu1.setText("File");
        jMenu1.setFont(new java.awt.Font("微软雅黑", 0, 14));

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
                java.awt.event.KeyEvent.VK_Q,
                java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setText("Exit");
        jMenuItem1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenuItem1MouseClicked(evt);
            }
        });
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Help");
        jMenu2.setFont(new java.awt.Font("微软雅黑", 0, 14));

        jMenuItem2.setText("About");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem2);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
                getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel1)
                .addGroup(
                        layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(
                                        layout.createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.TRAILING,
                                                false)
                                                .addComponent(
                                                        jLabel2,
                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(
                                                        javax.swing.GroupLayout.Alignment.LEADING,
                                                        layout.createSequentialGroup()
                                                                .addComponent(
                                                                        jLabel3)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addGroup(
                                                                        layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addGroup(
                                                                                        layout.createSequentialGroup()
                                                                                                .addGap(10,
                                                                                                        10,
                                                                                                        10)
                                                                                                .addComponent(
                                                                                                        jButton1)
                                                                                                .addGap(47,
                                                                                                        47,
                                                                                                        47)
                                                                                                .addComponent(
                                                                                                        jButton2))
                                                                                .addComponent(
                                                                                        jPasswordField1)
                                                                                .addComponent(
                                                                                        jTextField1,
                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                        197,
                                                                                        Short.MAX_VALUE))
                                                                .addContainerGap()))));
        layout.setVerticalGroup(layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(
                        layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(
                                        layout.createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel2)
                                                .addComponent(
                                                        jTextField1,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        24,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(
                                        layout.createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel3)
                                                .addComponent(
                                                        jPasswordField1,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        23,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(
                                        layout.createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jButton1)
                                                .addComponent(jButton2))
                                .addContainerGap(
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)));

        pack();
    }// </editor-fold>
        // GEN-END:initComponents

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {

        // TODO add your handling code here:
        About.start();
    }

    private void jPasswordField1KeyTyped(java.awt.event.KeyEvent evt) {
        if (evt.getKeyChar() == '\n') {
            String name = jTextField1.getText(); // 获取用户名
            String pass = String.valueOf(jPasswordField1.getPassword());// 获取密码
            User user = null;

            // 未输入用户名
            if (name.equals("") || name == null) {
                JOptionPane.showMessageDialog(this, "用户名不允许为空!", "cuowu", 0);
                return;
            }
            try {
                user = DAOFactory.getIUserDAOInstance().findById(name);
                if (user != null) {
                    if (user.getPass() != null && user.getPass().equals(pass)) {

                        GlobalUser.LOGIN_USER = user; // 记录当前用户

                        // 进入主界面
                        Main.start();
                        this.dispose();
                    } else {
                        JOptionPane.showMessageDialog(this, "用户名或密码错误!");
                        return;
                    }
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (user == null) {
                JOptionPane.showMessageDialog(this, "用户名或密码错误!", "消息", 0);
                return;
            }

        }

    }

    private void formKeyTyped(java.awt.event.KeyEvent evt) {

    }

    private void formKeyPressed(java.awt.event.KeyEvent evt) {

    }

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        jTextField1.setText("");
        jPasswordField1.setText("");
        jTextField1.requestFocus();

    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        String name = jTextField1.getText(); // 获取用户名
        String pass = String.valueOf(jPasswordField1.getPassword());// 获取密码
        User user = null;

        // 未输入用户名
        if (name.equals("")) {
            JOptionPane.showMessageDialog(this, "用户名不允许为空!");
            return;
        }
        try {
            user = DAOFactory.getIUserDAOInstance().findById(name);
            if (user != null) {
                if (user.getPass() != null && user.getPass().equals(pass)) {

                    GlobalUser.LOGIN_USER = user; // 记录当前用户

                    // 进入主界面
                    Main.start();
                    this.dispose();
                } else {
                    JOptionPane.showMessageDialog(this, "用户名或密码错误!", "消息", 0);
                    return;
                }
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (user == null) {
            JOptionPane.showMessageDialog(this, "用户名或密码错误!", "消息", 0);
            return;
        }

    }

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
        if (JOptionPane.showConfirmDialog(this, "你确定要退出吗?", "提示",
                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
            System.exit(0);
        }
    }

    private void jMenuItem1MouseClicked(java.awt.event.MouseEvent evt) {
        System.exit(1);
    }

    /**
     * @param args
     *            the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Login().setVisible(true);
            }
        });
    }

    // GEN-BEGIN:variables
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

计算机程序

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值