zoukankan      html  css  js  c++  java
  • Java小项目之:图书馆管理系统!

    Java小项目之:有借有还,再借不难!图书馆管理系统

    今天给大家分享的java小项目是图书馆管理系统。

    这个图书馆管理系统是很完善的,包括书籍信息录入、借阅者信息、书籍类别添加、新书订购等等功能。和现实生活中的图书馆管理系统没什么两样,毫不夸张的说,你只要学会了今天我分享的这个小项目,以后自己创建一个图书馆管理系统是没一点问题的。

    按照惯例先上图:

     

    部分代码展示:

     

    public class BookLoginIFrame extends JFrame {

    private class BookResetAction implements ActionListener {

    public void actionPerformed(final ActionEvent e){

    username.setText("");

    password.setText("");

    }

    }

    class BookLoginAction implements ActionListener {

    public void actionPerformed(final ActionEvent e) {

    user = Dao.check(username.getText(), password.getText());

    if (user.getName() != null) {

    try {

    Library frame = new Library();

    frame.setVisible(true);

    BookLoginIFrame.this.setVisible(false);

    } catch (Exception ex) {

    ex.printStackTrace();

    }

    } else {

    JOptionPane.showMessageDialog(null, "只有管理员才可以登录!");

    username.setText("");

    password.setText("");

    }

    }

    }

    private JPasswordField password;

    private JTextField username;

    private JButton login;

    private JButton reset;

    private static Operater user;

    /**

     * Launch the application

     * @param args

     */

    /**

     * Create the frame

     */

    public BookLoginIFrame() {

    super();

    final BorderLayout borderLayout = new BorderLayout();

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    borderLayout.setVgap(10);

    getContentPane().setLayout(borderLayout);

    setTitle("图书馆管理系统登录");

    setBounds(100, 100, 285, 194);

    final JPanel panel = new JPanel();

    panel.setLayout(new BorderLayout());

    panel.setBorder(new EmptyBorder(0, 0, 0, 0));

    getContentPane().add(panel);

    final JPanel panel_2 = new JPanel();

    final GridLayout gridLayout = new GridLayout(0, 2);

    gridLayout.setHgap(5);

    gridLayout.setVgap(20);

    panel_2.setLayout(gridLayout);

    panel.add(panel_2);

    final JLabel label = new JLabel();

    label.setHorizontalAlignment(SwingConstants.CENTER);

    label.setPreferredSize(new Dimension(0, 0));

    label.setMinimumSize(new Dimension(0, 0));

    panel_2.add(label);

    label.setText("用  户  名:");

    username = new JTextField(20);

    username.setPreferredSize(new Dimension(0, 0));

    panel_2.add(username);

    final JLabel label_1 = new JLabel();

    label_1.setHorizontalAlignment(SwingConstants.CENTER);

    panel_2.add(label_1);

    label_1.setText("密      码:");

    password = new JPasswordField(20);

    password.setDocument(new MyDocument(6));

    password.setEchoChar('*');//设置密码框的回显字符

    password.addKeyListener(new KeyAdapter() {

    public void keyPressed(final KeyEvent e) {

    if (e.getKeyCode() == 10)

    login.doClick();

    }

    });

    panel_2.add(password);

    final JPanel panel_1 = new JPanel();

    panel.add(panel_1, BorderLayout.SOUTH);

    login=new JButton();

    login.addActionListener(new BookLoginAction());

    login.setText("登录");

    panel_1.add(login);

    reset=new JButton();

    reset.addActionListener(new BookResetAction());

    reset.setText("重置");

    panel_1.add(reset);

    final JLabel tupianLabel = new JLabel();

    ImageIcon loginIcon=CreatecdIcon.add("login.jpg");

    tupianLabel.setIcon(loginIcon);

    tupianLabel.setOpaque(true);

    tupianLabel.setBackground(Color.GREEN);

    tupianLabel.setPreferredSize(new Dimension(260, 60));

    panel.add(tupianLabel, BorderLayout.NORTH);

    //

    setVisible(true);

    setResizable(false);

    //setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    }

    public static Operater getUser() {

    return user;

    }

    public static void setUser(Operater user) {

    BookLoginIFrame.user = user;

    }

    }

    需要这个图书馆管理系统素材和源码的小伙伴可以私信我领取,当然我不止有这点资料!

     

    喜欢这样文章的可以关注我,我会持续更新,你们的关注是我更新的动力!

    祝关注我的人都:身体健康,财源广进,福如东海,寿比南山,早生贵子,从不掉发

  • 相关阅读:
    LFU
    poj 3581 -- 后缀数组
    leetcode 679
    poj 两条线段接雨水
    poj 1696极角排序
    判断平面上是否有一条直线与所有线段相交
    洛谷P3808 【模板】AC自动机(简单版)
    Most Distant Point from the Sea UVA
    P2742 [USACO5.1]圈奶牛Fencing the Cows /【模板】二维凸包
    P2249
  • 原文地址:https://www.cnblogs.com/heqingxiaohuo/p/12192728.html
Copyright © 2011-2022 走看看