用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);
}
});
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
mvc设计模式,分包
分包图片
具体的MVC,已经在上一个项目中介绍了。可以看图书管理系统。这个项目。
简单效果演示:
登陆主页面
注册页面
登录:
登陆成功!
功能页面!
存款,取款,转账之前跳转的页面
存款
存款后的金额改变了
转账
转账成功!
转账后的金额
查看近期流水账单!
详细的可以了解,资源里边的项目。