温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Java实现图书馆管理系统代码

发布时间:2020-06-05 20:44:22 来源:亿速云 阅读:363 作者:Leah 栏目:编程语言

这篇文章给大家分享的是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; }}

以上就是Java实现图书馆管理系统的方法介绍,详细使用情况还得要大家自己使用过才能知道具体要领。如果想阅读更多相关内容的文章,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI