栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

JAVA编写银行系统(程序简单,欢迎指正)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

JAVA编写银行系统(程序简单,欢迎指正)

package 银行系统;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.event.*;
import java.awt.Font.*;
public class 主页面 extends Bank{
	 static JTabbedPane t = new JTabbedPane();
	static JMenuBar f=new JMenuBar ();
	static JMenu a1=new JMenu("系统");
	static JMenu a2=new JMenu("账户");
	 static JMenuItem c1=new JMenuItem("退出系统");
	 static  JMenuItem c2=new JMenuItem("退出登录");
	 static  JMenuItem c3=new JMenuItem("切换账号");
	 static JMenuItem c4=new JMenuItem("用户登录");
	 static JMenuItem c5=new JMenuItem("用户注册");
	 static JMenuItem c6=new JMenuItem("个人信息");
	 static JButton b3=new JButton("存款");
	 static JButton b4=new JButton("取款");
	 static JButton b5=new JButton("转账");
	 static JButton b6=new JButton("交易记录");
	 static JPanel d1=new  JPanel();
	 static JPanel d2=new  JPanel();
	 static Component panel1 = d3();
	 static Component panel2 = d4();
	 static Component panel3 = d5();
	 static Component panel4 = d6();
	 static Component panel5 = d7();
	 static Component panel6 = d8();
	 static Component panel7 = d9();
	 static Component panel8 = d10();
	 static Component panel9 = d11();
	 static Jframe w1=new Jframe("银行系统");
	public static void main(String args[]) {
	w1.setBounds(300,300,600,500);
	Container con = w1.getContentPane();
	con.setBackground(Color.white);
	BorderLayout a=new	BorderLayout();
	con.setLayout(a);
	JLabel c = new JLabel("欢迎光临银行!请操作");
	c.setSize(50,50);
	d1.setBackground(Color.white);
	GridLayout y=new GridLayout(2,1);
	d1.setLayout(y);
	d2.setLayout(y);
	f.add(a1);
	f.add(a2);
	w1.setJMenuBar(f);
	con.add(c,BorderLayout.NORTH);
	a1.add(c1);
    a1.addSeparator();
    a1.add(c2);
    a1.addSeparator();
    a1.add(c3);
    a1.addSeparator();
    a2.add(c4);
    a2.addSeparator();
    a2.add(c5);
    a2.addSeparator();
    a2.add(c6);
    a2.addSeparator();
    d2.add(b3);
    d2.add(b4);
    d2.add(b5);
    d2.add(b6);
    con.add(d1,BorderLayout.CENTER);
    con.add(d2,BorderLayout.SOUTH);
    con.add(t);
    PoliceListener listener=new PoliceListener();
    c1.addActionListener(listener);
	c2.addActionListener(listener);
	c3.addActionListener(listener);
	c4.addActionListener(listener);
	c5.addActionListener(listener);
	c6.addActionListener(listener);
	b3.addActionListener(listener);
	b4.addActionListener(listener);
	b5.addActionListener(listener);
	b6.addActionListener(listener);
	w1.setVisible(true);
	
	}
	
	}
 class PoliceListener extends 主页面 implements ActionListener {
	
	 public void actionPerformed(ActionEvent e) {
		if(e.getSource().equals(c1)){
			Bank.A1();
			}
			 if(e.getSource().equals(c2)) { 
				  
				t.addTab("退出登录",null,panel1,"");
				}
			 if(e.getSource().equals(c3)) { 
				 
				t.addTab("切换账号",null,panel7,"");
				}
	         if(e.getSource().equals(c4)) {
	        	 
	        	 t.addTab("用户登录",null,panel8,"");}
				 if(e.getSource().equals(c5)) {  
					
					 t.addTab("用户注册",null,panel9,"");
			}
	         if(e.getSource().equals(c6)) { 
	        	 
	        	t.addTab("个人信息",null,panel2,"");
	        }
	        	
	       if(e.getSource().equals(b3)) { 
	    	   
	        	t.addTab("存款",null,panel3,"");
	        }
	       if(e.getSource().equals(b4)) { 
	    	   
	        	t.addTab("取款",null,panel4,"");
	        }
	         if(e.getSource().equals(b5)) { 
	        	 
	        	t.addTab("转账",null,panel5,"");
	        }
	        if(e.getSource().equals(b6)) { 
	        	
	        	t.addTab("交易记录",null,panel6,"");
	        }
		}

	
}

 
 
package 银行系统;
import java.awt.*;

import java.awt.event.ActionListener;
import java.util.Vector;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.event.*;
import java.awt.Font.*;
public class Bank {
	static String[] name = {"miumiu","存款/取款","金额","时间","余额","cn"};
	static String[][] ww = {
			{"miumiu","存款","20000","20200224","21000","cn"},
			{"miumiu","取款","1000","20210406","20000","cn"},
			{"miumiu","转账","1500","20211111","18500","cn"},
			};
	static int r=18500;
	static DefaultTableModel tableModel=new DefaultTableModel(ww,name);
	static JTable t1=new JTable(tableModel);
	public static void A1() {
			System.exit(0);
		}
		protected static Component d3() {
			JPanel v1=new JPanel();
			v1.setBackground(Color.green);
			JLabel w1=new JLabel("祝您心情愉悦");
			v1.add(w1);
			return v1;
			}
		protected static Component d9() {
			JPanel v1=new JPanel();
			JComboBoxj1=new JComboBox();
			j1.addItem("miumiu");
			j1.addItem("haha");
			v1.add(j1);
			return v1;
		}
        protected static Component d10() {
			JPanel v1=new JPanel();
			JLabel w1=new JLabel("账号");
			JLabel w2=new JLabel("密码");
			JTextField w3 =new JTextField(10);
			JTextField w4=new JTextField(10);
			JButton w5=new JButton("登录");
			JButton w6=new JButton("取消");
			v1.add(w1);
			v1.add(w3);
			v1.add(w2);
			v1.add(w4);
			v1.add(w5);
			v1.add(w6);
			w5.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
							if (w4.getText().equals("23456")&&w3.getText().contentEquals("miumiu")) {
								JOptionPane.showMessageDialog(null, "账号"+w3.getText()+"密码"+w4.getText(), "个人信息", JOptionPane.NO_OPTION); 

							}
							if (!w4.getText().equals("23456")){
							JOptionPane.showMessageDialog(null, "密码错误","消息",JOptionPane.ERROR_MESSAGE);
					}
					}
			});
		w6.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				w3.setText("");
				w4.setText("");
			}
		});
			return v1;
		}
        protected static Component d11() {
	    JPanel v1=new JPanel();
	    BorderLayout w=new BorderLayout(5,1);
	    JLabel  v2=new JLabel("账号与密码不超过6位!");
	    JLabel w1=new JLabel("请输入账号:"); 
	    JLabel w2=new JLabel("请输入密码:");
	   
	    JTextField w4 =new JTextField(10);
		JTextField w5=new JTextField(10);
		JButton w7=new JButton("确认注册");
		JButton w8=new JButton("取消");
		v1.add(w1);
		v1.add(w4);
		v1.add(w2);
		v1.add(w5);
		v1.add(w7);
		v1.add(w8);
		v1.add(v2,BorderLayout.SOUTH);
		w7.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(e.getSource().equals(w7)) {
					JOptionPane.showMessageDialog(null, "注册成功", "消息", JOptionPane.NO_OPTION); 
				}
				}
		});
	w8.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			w4.setText("");
			w5.setText("");
			}
	});
	return v1;
}
		protected static Component d4() {
			JPanel v2=new JPanel();
			JLabel w1=new JLabel("姓名:miumiu");
			JLabel w2=new JLabel("性别:女");
			JLabel w3=new JLabel("账号:123456");
			JLabel w4=new JLabel("密码:******");
			JButton w5=new JButton("查看密码");
			v2.add(w1);
			v2.add(w2);
			v2.add(w3);
			v2.add(w4);
			v2.add(w5);
			w5.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					if(e.getSource().equals(w5)) {
						JOptionPane.showMessageDialog(null, "23456", "密码", JOptionPane.NO_OPTION); 
					}
					}
			});
			return v2;
		}
		protected static Component d5() {
			JPanel v3 = new JPanel();
			JLabel w3 = new JLabel("存款金额");
		    JTextField w4 = new JTextField(10);
		    JLabel w5 = new JLabel("存款时间");
		    JTextField w6 = new JTextField(10);
			JButton w7 = new JButton("确认");
			JButton w8 = new JButton("取消");
			v3.add(w3);
			v3.add(w4);
			v3.add(w5);
			v3.add(w6);
			v3.add(w7);
			v3.add(w8);
			w7.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					String money = w4.getText();
					String time = w6.getText();
					int a=Integer.parseInt(money);
					int a1=Integer.parseInt(time);
					int a4;
					 a4=r+a;
					 r=a4;
					 tableModel.addRow(new String[]{"miumiu","存款",money,time,String.valueOf(r),"cn"});
						int rowCount=t1.getRowCount()+1;
				    JOptionPane.showMessageDialog(null, "当前账户余额为:"+a4+"元n"+"存款时间为:"+a1,"消息",JOptionPane.PLAIN_MESSAGE);
				   
				    
				}
				
			});
			w8.addActionListener(new ActionListener() {  
				public void actionPerformed(ActionEvent e) {
					w4.setText("");
					w6.setText("");
				}
			});
			return v3;
		}
		protected static Component d6() {
			 JPanel v4 = new JPanel();
			 JLabel w1=new JLabel("取款金额");
			 JTextField w2 = new JTextField(10);
			 JLabel w3= new JLabel("取款时间");
			 JTextField w4 = new JTextField(10);
			JButton w7 = new JButton("确认");
			JButton w8 = new JButton("取消");
			v4.add(w1);
			v4.add(w2);
			v4.add(w3);
			v4.add(w4);
			v4.add(w7);
			v4.add(w8);
			w7.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					
					String money =w2.getText();
					String time = w4.getText();
					int a=Integer.parseInt(money);
					int a1=Integer.parseInt(time);
					if(r>a) {
						int a3;
					 a3=r-a;
				    JOptionPane.showMessageDialog(null, "当前账户余额为:"+a3+"元n"+"存款时间为:"+a1,"消息",JOptionPane.PLAIN_MESSAGE);
				    r=a3;
				    tableModel.addRow(new String[]{"miumiu","取款",money,time,String.valueOf(r),"cn"});
					int rowCount=t1.getRowCount()+1;
					}
					else {
						JOptionPane.showMessageDialog(null, "余额不足,重新输入","消息",JOptionPane.PLAIN_MESSAGE);
					}
					
				}
			});
			w8.addActionListener(new ActionListener() {  
				public void actionPerformed(ActionEvent e) {
					w2.setText("");
					w4.setText("");
				}
			});
			return v4;
		}
		
		protected static Component d7() {
			JPanel v5 = new JPanel();
			JLabel w1 = new JLabel("转账账户:");
			JTextField w3 =new JTextField(10);
			JLabel w2 = new JLabel("转账金额:");
			JTextField w4=new JTextField(10);
			JLabel w8 = new JLabel("转账时间:");
			JTextField w7=new JTextField(10);
			JButton w5= new JButton("重新输入");
			JButton w6= new JButton("确认");
			v5.add(w1);
			v5.add(w3);
		    v5.add(w2);
			v5.add(w4);
			v5.add(w8);
			v5.add(w7);
			v5.add(w5);
			v5.add(w6);
			
			w5.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					w3.setText("");
					w4.setText("");
					w7.setText("");
				}
			});
			w6.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					String money =w4.getText();
					String time = w7.getText();
					int a=Integer.parseInt(money);
					int a1=Integer.parseInt(time);
					if(a 

本人是小菜鸟,欢迎大家指正哦

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/750719.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号