这篇文章给大家介绍使用java编写一个银行管理系统,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
package org.vector.view; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPasswordField; import javax.swing.JTextField; import org.vector.bean.Bank; import org.vector.serviceImpl.BankServiceImpl; @SuppressWarnings("serial") public class BankView extends JFrame{ private JButton register,login,codeChange; private JLabel idLabel,codeLabel,bank,imLabel; public static JTextField idTest; private JPasswordField codeTest; public static String message; public BankView() { building(); addListeners(); } public void building() { setLayout(null); ImageIcon image = new ImageIcon("bank.png"); imLabel = new JLabel(image); imLabel.setBounds(180, 90, 250, 200); bank = new JLabel("bank"); idLabel = new JLabel("账号"); codeLabel = new JLabel("密码"); register = new JButton("注册"); login = new JButton("登录"); image = new ImageIcon("bank.png"); idTest = new JTextField(20); codeTest = new JPasswordField(20); codeChange = new JButton("修改/忘记密码"); bank.setBounds(250, 20, 120, 50); Font font = new Font("圆体", Font.BOLD, 50); Font font1 = new Font("圆体", Font.BOLD, 30); bank.setFont(font); register.setBounds(0, 500, 120, 25); login.setBounds(225, 450, 120, 25); codeChange.setBounds(450, 500, 120, 25); idLabel.setBounds(150, 300, 120, 25); idLabel.setFont(font1); codeLabel.setBounds(150, 375, 120, 25); codeLabel.setFont(font1); idTest.setBounds(250, 300, 200, 30); codeTest.setBounds(250, 375, 200, 30); add(bank); add(imLabel); add(idLabel); add(idTest); add(codeLabel); add(codeTest); add(login); add(register); add(codeChange); setBounds(600,600,600,600); setLocation((2000-getWidth())/2,(1000-getHeight())/2); setResizable(false); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setVisible(true); } private void addListeners() { register.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BankView.this.dispose(); new BankRegister().setVisible(true); } }); login.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub int flag = 0; String id = idTest.getText(); String code = codeTest.getText(); if(!id.equals("")&&!code.equals("")) { BankServiceImpl bankServiceImpl = new BankServiceImpl(); BankView_0.list.clear(); BankView_0.list.addAll(bankServiceImpl.find()); for (int i = 0; i < BankView_0.list.size(); i++) { if(id.equals(BankView_0.list.get(i).getIdAccount()) && code.equals(BankView_0.list.get(i).getCode())) { BankView_0.list1.clear(); BankView_0.list1.add(id); flag = 1; JOptionPane.showMessageDialog(register, "登陆成功", "标题",JOptionPane.WARNING_MESSAGE); BankView.this.dispose(); new BankView_0().setVisible(true); break; } } if(flag == 0){ JOptionPane.showMessageDialog(register, "账号或密码错误", "标题",JOptionPane.WARNING_MESSAGE); } } else { JOptionPane.showMessageDialog(register, "账号或密码不能为空", "标题",JOptionPane.WARNING_MESSAGE); } } }); codeChange.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub JOptionPane.showMessageDialog(codeChange, "此功能暂未开放", "标题",JOptionPane.WARNING_MESSAGE); } }); } }
具体的MVC,已经在上一个项目中介绍了。可以看图书管理系统。这个项目。
登陆成功!
存款,取款,转账之前跳转的页面
存款后的金额改变了
转账成功!
转账后的金额
关于使用java编写一个银行管理系统就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。