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实现简单的银行管理系统的文章就介绍到这了,更多相关java银行管理系统内容请搜索呐喊教程以前的文章或继续浏览下面的相关文章希望大家以后多多支持呐喊教程!
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:notice#nhooo.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。