收藏 分享(赏)

java项目 ATM银行系统 源代码.doc

上传人:精品资料 文档编号:10701974 上传时间:2019-12-29 格式:DOC 页数:44 大小:319.50KB
下载 相关 举报
java项目 ATM银行系统 源代码.doc_第1页
第1页 / 共44页
java项目 ATM银行系统 源代码.doc_第2页
第2页 / 共44页
java项目 ATM银行系统 源代码.doc_第3页
第3页 / 共44页
java项目 ATM银行系统 源代码.doc_第4页
第4页 / 共44页
java项目 ATM银行系统 源代码.doc_第5页
第5页 / 共44页
点击查看更多>>
资源描述

1、/初始密码为 123456import java.awt.*;import java.awt.event.*;import javax.swing.*;public class MyATM extends JFrame implements ActionListenerJPanel panelfirst,panelmain,panel3,panel4,panel5,panel6,panel7,panelchangepwd,panelchangepwded,panelsave,panelsaved,panelremain,paneltrans,paneltransed,panelmobile,p

2、anelmobiled,panelconsult;JButton btn0,btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10,btnsure,btnback,btnok,btncard,btngetcard,btnincard;JButton btn00,btn01,btn02,btn03,btn04,btn05,btn06,btn07,btn08,btn09,btn010,btnback1,btnremain,btnremain1,btnremain2;JButton btn000,btn001,btn002,btn003,btn004,b

3、tn005,btn006,btn007,btn008,btn009,btn100,btn200,btn300,btn1000,btn500,btnsure1,btnback2,btn0010,btnquok1,btnquok2,btnquok3,btnquok4;JButton btnpwd,btnpwd1,btnpwd2,btnpwd3,btnpwd4,btn11,btn12,btn13,btn14,btn15,btn16,btn17,btn18,btn19,btn20,btnsave,btnsave1,btnsave2,btnsaved,btnsaved1,btnsaved2,btnsav

4、ed3;JButton btntra,btntra1,btntra2,btntraed,btntraed1,btn21,btn22,btn23,btn24,btn25,btn26,btn27,btn28,btn29,btn30,btncon,btncon1;JButton btnmo,btnmo1,btnmo2,btnmo30,btnmo50,btnmo100,btnmo200,btnmo500,btnmo10,btnmo11,btnmo12,btnmo13,btnmo14,btnmo15,btnmo16,btnmo17,btnmo18,btnmo19,btnmoed,btnmoed1;JTe

5、xtField txt2,txttrans,txttrans1,txttrans2,txtmo,txtmo1;JLabel lbljixu,lblpwd,lblwrong,lblqukuan,lblquok1,lblquok2,lblpwd1,lblpwd2,lblpwd3,lblpwd4,lblsave,lblsave1,lblsaved,lblremain,lblremain1,lbltra,lbltra1,lbltra2,lbltraed,lbltraed1;JLabel lblwel,lblwel1,lblmo,lblmo1,lblmo2,lblmo3,lblmoed,lblmoed1

6、,lblcon,lblcon1;JPasswordField txt1,txtpwd,txtpwd1;Container container;CardLayout Layout;int money,savemoney,mobilemoney=0;double lastmoney,trainsmoney;String userpwd,cardnum,trains,username;boolean flag=true,flag1=false,flag2=false,flag3=true,flag4=false,flag5=false;/构造方法public MyATM()super(“罗灿银行“

7、);this.setSize(435,350);this.setLocation(500, 250);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );/设置不可改变窗口大小this.setResizable(false); /设置程序小图标this.setIconImage(this.getToolkit().getImage(“imageshaizei.jpg“);/布局public void setLayout()/用卡片布局Layout=new CardLayout();container=getContentPane();con

8、tainer.setLayout(Layout);/添加第一张卡片panelfirst=new JPanel(null);/设置卡片的背景颜色panelfirst.setBackground(new Color(119,119,253);lbljixu=new JLabel(“请放入磁卡, 然后继续操作“);/设置卡片在Panel中的位置lbljixu.setBounds(140,90,350,30);/为第一张卡片添加一个Labelpanelfirst.add(lbljixu);/为第一张卡片添加一个按钮btncard=new JButton(“继续“);btncard.setBounds(

9、310,180,80,30);/为按钮注册事件监听器btncard.addActionListener(this);/开始时设置按钮不可按btncard.setEnabled(false);panelfirst.add(btncard);/为第一张卡片添加一个按钮btngetcard=new JButton(“取卡“ );btngetcard.setEnabled(false);btngetcard.setBounds(310,220,80,30);btngetcard.addActionListener(this);panelfirst.add(btngetcard);/为第一张卡片添加一个

10、按钮btnincard=new JButton(“插卡“);btnincard.setBounds(40,220,80,30);btnincard.addActionListener(this);panelfirst.add(btnincard);container.add(panelfirst,“first“);/添加登录输入密码卡片panelmain=new JPanel(null);panelmain.setBackground(new Color(119,119,253);lblpwd=new JLabel(“请输入您的银行卡密码: “);panelmain.add(lblpwd);l

11、blpwd.setBounds(150, 20, 150, 30);/设置文本框为密码型txt1=new JPasswordField(12);/文本框不可选中txt1.enable(false);panelmain.add(txt1);/文本框的输入内容用*显示txt1.setEchoChar(*);txt1.setBounds(115,50,200,30);/添加选择按钮btnsure=new JButton(“确定“);btnsure.addActionListener(this);panelmain.add(btnsure);btnsure.setBounds(70,160,80,30

12、);/添加重输按钮btn010=new JButton(“重输“ );btn010.addActionListener(this);panelmain.add(btn010);btn010.setBounds(175,160,80,30);btnback=new JButton(“退出“);btnback.addActionListener(this);panelmain.add(btnback);btnback.setBounds(280,160,80,30);lblwrong=new JLabel(“请注意保护好您的密码!“);panelmain.add(lblwrong);lblwron

13、g.setBounds(150,90,200,30);/添加输入按钮btn01=new JButton(“1“);btn01.addActionListener(this);panelmain.add(btn01);btn01.setBounds(45,210,60,30);btn02=new JButton(“2“);btn02.addActionListener(this);panelmain.add(btn02);btn02.setBounds(115,210,60,30);btn03=new JButton(“3“);btn03.addActionListener(this);pane

14、lmain.add(btn03);btn03.setBounds(185,210,60,30);btn04=new JButton(“4“);btn04.addActionListener(this);panelmain.add(btn04);btn04.setBounds(255,210,60,30);btn05=new JButton(“5“);btn05.addActionListener(this);panelmain.add(btn05);btn05.setBounds(325,210,60,30);btn06=new JButton(“6“);btn06.addActionList

15、ener(this);panelmain.add(btn06);btn06.setBounds(45,260,60,30);btn07=new JButton(“7“);btn07.addActionListener(this);panelmain.add(btn07);btn07.setBounds(115,260,60,30);container.add(panelmain,“main“);btn08=new JButton(“8“);btn08.addActionListener(this);panelmain.add(btn08);btn08.setBounds(185,260,60,

16、30);btn09=new JButton(“9“);btn09.addActionListener(this);panelmain.add(btn09);btn09.setBounds(255,260,60,30);btn00=new JButton(“0“);btn00.addActionListener(this);panelmain.add(btn00);btn00.setBounds(325,260,60,30);/添加主界面卡片panel3=new JPanel(null);panel3.setBackground(new Color(119,119,253);lblwel=new

17、 JLabel(username+“,欢迎使用罗灿银行ATM 系统“ );lblwel.setBounds(20,15,350,30);panel3.add(lblwel);lblwel1=new JLabel(“请选择您需要的交易类型 “);lblwel1.setBounds(220,55,350,30);panel3.add(lblwel1);btn3=new JButton(“取款服务“ );btn3.addActionListener(this);btn3.setBounds(20,90,100,30);panel3.add(btn3);btn4=new JButton(“修改密码“

18、);btn4.addActionListener(this);btn4.setBounds(20,150,100,30);panel3.add(btn4);btn5=new JButton(“存款服务“ );btn5.addActionListener(this);btn5.setBounds(20,210,100,30);panel3.add(btn5);btn6=new JButton(“查询余额“ );btn6.addActionListener(this);btn6.setBounds(20,270,100,30);panel3.add(btn6);btn7=new JButton(“

19、转账服务“ );btn7.addActionListener(this);btn7.setBounds(300,90,100,30);panel3.add(btn7);btn8=new JButton(“通信交费“ );btn8.addActionListener(this);btn8.setBounds(300,150,100,30);panel3.add(btn8);btn9=new JButton(“咨询服务“ );btn9.addActionListener(this);btn9.setBounds(300,210,100,30);panel3.add(btn9);btn10=new

20、JButton(“退出操作“);btn10.addActionListener(this);btn10.setBounds(300,270,100,30);panel3.add(btn10);container.add(panel3,“three“);/添加取款页面卡片panel4=new JPanel(null);panel4.setBackground(new Color(119,119,253);lblqukuan=new JLabel(“请输入您的取款数:“);panel4.add(lblqukuan);lblqukuan.setBounds(115, 20, 150, 30);lbl

21、qukuan=new JLabel(“提示:只能是100 元或100 元的整数倍。“ );panel4.add(lblqukuan);lblqukuan.setBounds(115, 50, 300, 30);txt2=new JTextField(12);txt2.enable(false);panel4.add(txt2);txt2.setBounds(115,90,200,30);btn100=new JButton(“100“);panel4.add(btn100);btn100.addActionListener(this);btn100.setBounds(45,190,60,30

22、);btn200=new JButton(“200“);panel4.add(btn200);btn200.addActionListener(this);btn200.setBounds(115,190,60,30);btn300=new JButton(“300“);panel4.add(btn300);btn300.addActionListener(this);btn300.setBounds(185,190,60,30);btn500=new JButton(“500“);panel4.add(btn500);btn500.addActionListener(this);btn500

23、.setBounds(255,190,60,30);btn1000=new JButton(“1000“);panel4.add(btn1000);btn1000.addActionListener(this);btn1000.setBounds(325,190,65,30);btn001=new JButton(“1“);panel4.add(btn001);btn001.addActionListener(this);btn001.setBounds(45,230,60,30);btn002=new JButton(“2“);panel4.add(btn002);btn002.addAct

24、ionListener(this);btn002.setBounds(115,230,60,30);btn003=new JButton(“3“);panel4.add(btn003);btn003.addActionListener(this);btn003.setBounds(185,230,60,30);btn004=new JButton(“4“);panel4.add(btn004);btn004.addActionListener(this);btn004.setBounds(255,230,60,30);btn005=new JButton(“5“);panel4.add(btn

25、005);btn005.addActionListener(this);btn005.setBounds(325,230,65,30);btn006=new JButton(“6“);panel4.add(btn006);btn006.addActionListener(this);btn006.setBounds(45,270,60,30);btn007=new JButton(“7“);panel4.add(btn007);btn007.addActionListener(this);btn007.setBounds(115,270,60,30);btn008=new JButton(“8

26、“);panel4.add(btn008);btn008.addActionListener(this);btn008.setBounds(185,270,60,30);btn009=new JButton(“9“);panel4.add(btn009);btn009.addActionListener(this);btn009.setBounds(255,270,60,30);btn000=new JButton(“0“);panel4.add(btn000);btn000.addActionListener(this);btn000.setBounds(325,270,65,30);btn

27、sure1=new JButton(“确定“ );panel4.add(btnsure1);btnsure1.addActionListener(this);btnsure1.setBounds(70,140,80,30);btn0010=new JButton(“重输“);panel4.add(btn0010);btn0010.addActionListener(this);btn0010.setBounds(175,140,80,30);btnback2=new JButton(“返回“ );panel4.add(btnback2);btnback2.addActionListener(t

28、his);btnback2.setBounds(280,140,80,30);container.add(panel4,“four“);/添加完成取款操作需要显示的卡片panel5=new JPanel(null);panel5.setBackground(new Color(119,119,253);lblquok1=new JLabel(“取款成功,你本次取款数额为“+txt2.getText()+ “,是否继续操作?“);lblquok1.setBounds(60, 110, 350, 30);panel5.add(lblquok1);btnquok1=new JButton(“继续取款

29、“ );panel5.add(btnquok1);btnquok1.addActionListener(this);btnquok1.setBounds(30, 185, 90, 30);btnquok2=new JButton(“打印凭条“ );panel5.add(btnquok2);btnquok2.addActionListener(this);btnquok2.setBounds(30, 240, 90, 30);btnquok3=new JButton(“其它操作“ );panel5.add(btnquok3);btnquok3.addActionListener(this);bt

30、nquok3.setBounds(300, 185, 90, 30);btnquok4=new JButton(“退出操作“ );panel5.add(btnquok4);btnquok4.addActionListener(this);btnquok4.setBounds(300, 240, 90, 30);container.add(panel5,“five“);/添加修改密码界面卡片panelchangepwd=new JPanel(null);panelchangepwd.setBackground(new Color(119,119,253);lblpwd1=new JLabel(“

31、请输入您需要修改的6位密码:“);lblpwd1.setBounds(115, 30, 300, 30);panelchangepwd.add(lblpwd1);lblpwd2=new JLabel(“请再次输入您需要修改的 6位密码:“);lblpwd2.setBounds(115, 110, 300, 30);panelchangepwd.add(lblpwd2);txtpwd=new JPasswordField(12);txtpwd.enable(false);txtpwd.setEchoChar(*);panelchangepwd.add(txtpwd);txtpwd.setBoun

32、ds(115,70,200,30);txtpwd1=new JPasswordField(12);txtpwd1.enable(false);txtpwd1.setEchoChar(*);panelchangepwd.add(txtpwd1);txtpwd1.setBounds(115,150,200,30);btnpwd=new JButton(“确定“ );panelchangepwd.add(btnpwd);btnpwd.addActionListener(this);btnpwd.setBounds(70,190,80,30);btnpwd1=new JButton(“重输“);pan

33、elchangepwd.add(btnpwd1);btnpwd1.addActionListener(this);btnpwd1.setBounds(175,190,80,30);btnpwd2=new JButton(“返回“);panelchangepwd.add(btnpwd2);btnpwd2.addActionListener(this);btnpwd2.setBounds(280,190,80,30);btn11=new JButton(“1“);panelchangepwd.add(btn11);btn11.addActionListener(this);btn11.setBou

34、nds(45,230,60,30);btn12=new JButton(“2“);panelchangepwd.add(btn12);btn12.addActionListener(this);btn12.setBounds(115,230,60,30);btn13=new JButton(“3“);panelchangepwd.add(btn13);btn13.addActionListener(this);btn13.setBounds(185,230,60,30);btn14=new JButton(“4“);panelchangepwd.add(btn14);btn14.addActi

35、onListener(this);btn14.setBounds(255,230,60,30);btn15=new JButton(“5“);panelchangepwd.add(btn15);btn15.addActionListener(this);btn15.setBounds(325,230,60,30);btn16=new JButton(“6“);panelchangepwd.add(btn16);btn16.addActionListener(this);btn16.setBounds(45,270,60,30);btn17=new JButton(“7“);panelchang

36、epwd.add(btn17);btn17.addActionListener(this);btn17.setBounds(115,270,60,30);btn18=new JButton(“8“);panelchangepwd.add(btn18);btn18.addActionListener(this);btn18.setBounds(185,270,60,30);btn19=new JButton(“9“);panelchangepwd.add(btn19);btn19.addActionListener(this);btn19.setBounds(255,270,60,30);btn

37、20=new JButton(“0“);panelchangepwd.add(btn20);btn20.addActionListener(this);btn20.setBounds(325,270,60,30);container.add(panelchangepwd,“changepwd“);/添加修改密码完成显示界面卡片panelchangepwded=new JPanel(null);panelchangepwded.setBackground(new Color(119,119,253);lblpwd3=new JLabel(“修改密码成功, 请妥善保管好您的密码。“);lblpwd

38、3.setBounds(90,70,350,30);panelchangepwded.add(lblpwd3);btnpwd3=new JButton(“继续操作“);btnpwd3.setBounds(95,110,90,30);btnpwd3.addActionListener(this);panelchangepwded.add(btnpwd3);btnpwd4=new JButton(“退出操作“);btnpwd4.setBounds(200,110,90,30);btnpwd4.addActionListener(this);panelchangepwded.add(btnpwd4)

39、;container.add(panelchangepwded,“changgepwded“);/添加存款显示界面卡片panelsave=new JPanel(null);panelsave.setBackground(new Color(119,119,253);lblsave=new JLabel(“请在存款口处放入存款 “);lblsave.setBounds(90,70,350,30);panelsave.add(lblsave);lblsave1=new JLabel(“请注意:只接收100 元或100 元的整数倍存款“ );lblsave1.setBounds(90,110,350

40、,30);panelsave.add(lblsave1);btnsave=new JButton(“放入存款完毕“);btnsave.setBounds(60,160,120,30);btnsave.addActionListener(this);panelsave.add(btnsave);btnsave1=new JButton(“继续“ );btnsave1.setBounds(200,160,60,30);btnsave1.addActionListener(this);panelsave.add(btnsave1);btnsave2=new JButton(“返回“ );btnsav

41、e2.setBounds(280,160,60,30);btnsave2.addActionListener(this);panelsave.add(btnsave2);container.add(panelsave,“save“);/添加存款完成显示界面卡片panelsaved=new JPanel(null);panelsaved.setBackground(new Color(119,119,253);lblsaved=new JLabel(“你本次的存款数额为“+savemoney+ “元,是否继续操作?“ );lblsaved.setBounds(85, 110, 350, 30);

42、panelsaved.add(lblsaved);btnsaved=new JButton(“继续存款“ );panelsaved.add(btnsaved);btnsaved.addActionListener(this);btnsaved.setBounds(30, 185, 90, 30);btnsaved1=new JButton(“打印凭条“);panelsaved.add(btnsaved1);btnsaved1.addActionListener(this);btnsaved1.setBounds(30, 240, 90, 30);btnsaved2=new JButton(“其

43、他操作“);panelsaved.add(btnsaved2);btnsaved2.addActionListener(this);btnsaved2.setBounds(300, 185, 90, 30);btnsaved3=new JButton(“退出操作“);panelsaved.add(btnsaved3);btnsaved3.addActionListener(this);btnsaved3.setBounds(300, 240, 90, 30);container.add(panelsaved,“saved“);/添加查询余额界面卡片panelremain=new JPanel(

44、null);panelremain.setBackground(new Color(119,119,253);lblremain1=new JLabel(“卡号:“+cardnum);lblremain1.setBounds(90,70,350,30);panelremain.add(lblremain1);lblremain=new JLabel(“您的余额为“ +lastmoney+“元,请继续您的操作!“);lblremain.setBounds(90,110,350,30);panelremain.add(lblremain);btnremain=new JButton(“继续操作“)

45、;btnremain.setBounds(95,150,90,30);btnremain.addActionListener(this);panelremain.add(btnremain);btnremain1=new JButton(“退出操作“ );btnremain1.setBounds(200,150,90,30);btnremain1.addActionListener(this);panelremain.add(btnremain1);container.add(panelremain,“remain“);/添加手机充值卡片界面paneltrans=new JPanel(null

46、);paneltrans.setBackground(new Color(119,119,253);lbltra=new JLabel(“请输入对方的19位帐号:“);lbltra.setBounds(20, 30, 160, 30);paneltrans.add(lbltra);lbltra1=new JLabel(“请再次输入对方的19位帐号:“);lbltra1.setBounds(20, 80, 190, 30);paneltrans.add(lbltra1);lbltra2=new JLabel(“请输入您的转账金额: “);lbltra2.setBounds(20, 130, 16

47、0, 30);paneltrans.add(lbltra2);txttrans=new JTextField(“6“,19);txttrans.enable(false);paneltrans.add(txttrans);txttrans.setBounds(200,30,200,30);txttrans1=new JTextField(“6“,19);txttrans1.enable(false);paneltrans.add(txttrans1);txttrans1.setBounds(200,80,200,30);txttrans2=new JTextField(“,19);txttra

48、ns2.enable(false);paneltrans.add(txttrans2);txttrans2.setBounds(200,130,200,30);btntra=new JButton(“确定“ );paneltrans.add(btntra);btntra.addActionListener(this);btntra.setBounds(70,190,80,30);btntra1=new JButton(“重输“);paneltrans.add(btntra1);btntra1.addActionListener(this);btntra1.setBounds(175,190,8

49、0,30);btntra2=new JButton(“返回“);paneltrans.add(btntra2);btntra2.addActionListener(this);btntra2.setBounds(280,190,80,30);btn21=new JButton(“1“);paneltrans.add(btn21);btn21.addActionListener(this);btn21.setBounds(45,230,60,30);btn22=new JButton(“2“);paneltrans.add(btn22);btn22.addActionListener(this);btn22.setBounds(115,230,60,30);btn23=new JButton(“3“);paneltrans.add(btn23);btn23.addActionListener(this);btn23.setBounds(185,230,60,30);btn24=new JButton(“4“);paneltrans.add(btn24);btn24.addActionListener(this);btn24.setBounds(255,230,60,30);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报