基于JavaSwing 银行管理系统

一、系统介绍

本项目是使用Java swing开发,可实现ATM系统/银行系统的基本登陆、查询余额、存取款业务。

二、系统展示

1.主页

2.用户开户

3.用户登陆

3.用户存款

4.用户取款

三、系统实现

BusinessPanel .java

package client;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;

import model.*;

public class BusinessPanel extends JPanel {
	//以下几个组件分别用来显示账户的信息
	private JLabel label1=new JLabel("账户:",SwingConstants.CENTER);
	private JLabel label2=new JLabel("姓名:",SwingConstants.CENTER);
	private JLabel label3=new JLabel("余额:",SwingConstants.CENTER);
	private JLabel label4=new JLabel("信用额度:",SwingConstants.CENTER);
	private JLabel label5=new JLabel("贷款额:",SwingConstants.CENTER);
	private JLabel accountLabel=new JLabel("",SwingConstants.CENTER);
	private JLabel nameLabel=new JLabel("",SwingConstants.CENTER);
	private JLabel balanceLabel=new JLabel("",SwingConstants.CENTER);
	private JLabel ceilingLabel=new JLabel("",SwingConstants.CENTER);
	private JLabel loanLabel=new JLabel("",SwingConstants.CENTER);
	//用来选择交易种类
	private JComboBox choiceBox=new JComboBox();
	//用来输入交易金额
	private JTextField inputField=new JTextField(15);
	private JButton okButton=new JButton("提交");
	private JButton backButton=new JButton("返回");
	public JComboBox getChoiceBox() {
		return choiceBox;
	}
	public JTextField getInputField() {
		return inputField;
	}
	public JButton getOkButton() {
		return okButton;
	}
	
	
	//构造方法用来设置常规的界面,但有些组件的文本内容需要根据Account对象来设置
	public BusinessPanel(){
		this.setBorder(new EmptyBorder(10,0,10,0));
		this.setLayout(new BorderLayout());
		
		JPanel p=new JPanel();
		p.setLayout(new GridLayout(5,2,0,10));
		p.add(label1);
		p.add(accountLabel);
		p.add(label2);
		p.add(nameLabel);
		p.add(label3);
		p.add(balanceLabel);
		p.add(label4);
		p.add(ceilingLabel);
		p.add(label5);
		p.add(loanLabel);
		
		p.setBackground(Color.ORANGE);//设置背景色
		this.add(p);
		
		JPanel p2=new JPanel();
		choiceBox.addItem("存款");
		choiceBox.addItem("取款");
		
		p2.add(choiceBox);
		p2.add(inputField);
		p2.add(okButton);
		p2.add(backButton);
		
		p2.setBackground(Color.DARK_GRAY);//设置背景色
		this.add(p2,"South");
	}
	
	//用来根据账户的类型设置组件,不需要的组件变灰
	public void initComponent(Account c){

		choiceBox.removeAllItems();
		
		choiceBox.addItem("存款");
		choiceBox.addItem("取款");
		
		label4.setEnabled(true);
		label5.setEnabled(true);
		if (c instanceof CreditAccount) {
			choiceBox.addItem("设置透支额度");
		}
		else{
			label4.setEnabled(false);
		}
		if (c instanceof Loanable){
			choiceBox.addItem("申请贷款");
			choiceBox.addItem("还贷款");
		}
		else{
			label5.setEnabled(false);
		}
	}
	//用来将账户的信息写在界面中
	public void setText(Account c){
		accountLabel.setText(c.getId()+"");
		nameLabel.setText(c.getName());
		balanceLabel.setText(c.getBalance()+"");
		if (c instanceof CreditAccount){
			CreditAccount ca=(CreditAccount)c;
			ceilingLabel.setText(ca.getCeiling()+"");
		}
		if (c instanceof Loanable){
			Loanable l=(Loanable)c;
			loanLabel.setText(l.getLoan()+"");
		}
	}
	public JButton getBackButton() {
		return backButton;
	}
	public void setBackButton(JButton backButton) {
		this.backButton = backButton;
	}
}

四、其他

1.其它系统

点击下载

经验分享 程序员 微信小程序 职场和发展