版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、登陆package com.userland;import java.awt.HeadlessException;import java.awt.Label;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;/* * 欢迎界面 * author Administrator * */public class Welcomeland extends J
2、FrameJPanel p1;private JButton btn1;Label label;static JframUserLand jf=null;public Welcomeland(String arg0) throws HeadlessException super(arg0);setSize(800, 600);p1 = new JPanel();label=new Label("XX银行欢迎登陆!");btn1 = new JButton("登陆");btn1.addActionListener(new MyActionListner()
3、;p1.add(btn1);p1.add(label);setContentPane(p1);public static void main(String args) Welcomeland myJframe = new Welcomeland("XX银行欢迎登陆!");myJframe.setVisible(true);class MyActionListner implements ActionListener Overridepublic void actionPerformed(ActionEvent arg0) Object o = arg0.getSource(
4、);if (o = btn1) jf=new JframUserLand("XX银行欢迎登陆!");jf.pack();setVisible(false);jf.setVisible(true);package com.userland;import java.awt.Frame;import java.awt.GridLayout;import java.awt.HeadlessException;import java.awt.Label;import java.awt.event.ActionEvent;import java.awt.event.ActionList
5、ener;import java.io.BufferedReader;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStreamReader;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JText
6、Field;import com.action.JframBank;/* * 登陆界面 * author Administrator * */public class JframUserLand extends JFrame private JButton btn1, btn2;static JTextField t1;static JPasswordField t2;JPanel p1;public JframUserLand(String arg0) throws HeadlessException super(arg0);setSize(800, 600);p1 = new JPanel
7、();Frame f = new Frame("用户登录");f.setLayout(new GridLayout(4, 2);btn2 = new JButton("确认");btn2.addActionListener(new MyActionListner();t1 = new JTextField("输入用户名", 15);t2 = new JPasswordField("输入密码", 15);f.add(new Label("用户名:", Label.CENTER);p1.add(t1
8、);f.add(new Label("密码:", Label.CENTER);p1.add(t2);p1.add(btn2);setContentPane(p1);this.setVisible(true);class MyActionListner implements ActionListener Overridepublic void actionPerformed(ActionEvent arg0) Object o = arg0.getSource();if (o = btn2) InputStreamReader isr;try isr = new InputS
9、treamReader(new FileInputStream("person.txt");BufferedReader Ia = new BufferedReader(isr);String a = Ia.readLine();String b = Ia.readLine();Ia.close();System.out.println(JframUserLand.t1.getText();if (JframUserLand.t1.getText().equals(a) if(JframUserLand.t2.getText().equals(b)JframBank jBa
10、nk = new JframBank("XX银行欢迎登陆!");jBank.setVisible(true);jBank.pack();setVisible(false);jBank.setVisible(true); else JframUserLand jframUserLand = new JframUserLand("XX银行欢迎登陆!");jframUserLand.setVisible(true);jframUserLand.pack();setVisible(false);jframUserLand.setVisible(true); ca
11、tch (FileNotFoundException e) / TODO Auto-generated catch blocke.printStackTrace(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();package com.action;import com.action.BTN1;import com.userland.Welcomeland;import java.awt.HeadlessException;import java.awt.Window;import jav
12、a.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.event.DocumentListener;/* * 主界面 * author Administrator * */public class JframBank extends JFrame private BTN1 b
13、t1 = null;static BTN2 bt2 = null;static BTN3 bt3 = null;static BTN4 bt4 = null;private JButton btn1, btn2, btn3, btn4, btn5;JPanel p1;public JframBank(String arg0) throws HeadlessException super(arg0);setSize(600, 400);p1 = new JPanel();btn1 = new JButton("查询");btn1.addActionListener(new J
14、();btn2 = new JButton("取款");btn2.addActionListener(new J();btn3 = new JButton("存钱");btn3.addActionListener(new J();btn4 = new JButton("转账");btn4.addActionListener(new J();btn5 = new JButton("退出");btn5.addActionListener(new J();p1.add(btn1);p1.add(btn2);p1.add(
15、btn3);p1.add(btn4);p1.add(btn5);setContentPane(p1);this.setVisible(true);class J implements ActionListener public void actionPerformed(ActionEvent arg0) Object o = arg0.getSource();if (o = btn1) bt1 = new BTN1("查询");bt1.pack();setVisible(false);bt1.setVisible(true);if (o = btn2) bt2 = new
16、BTN2("取款");bt2.pack();setVisible(false);bt2.setVisible(true);if (o = btn3) bt3 = new BTN3("存款");bt3.pack();setVisible(false);bt3.setVisible(true);if (o = btn4) bt4 = new BTN4("转账");bt4.pack();setVisible(false);bt4.setVisible(true);if (o = btn5) Welcomeland wel = new Wel
17、comeland("XX银行欢迎登陆!");wel.setVisible(true);wel.pack();setVisible(false);wel.setVisible(true);public BTN1 getBt1() return bt1;package com.action;import java.awt.HeadlessException;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.s
18、wing.JFrame;import javax.swing.JPanel;import javax.swing.JTextField;import com.action.JframBank;import com.userland.Welcomeland;/* * 查询界面 * * author Administrator * */public class BTN1 extends JFrame private JButton btn1, btn2;static JTextField t1;private JPanel b1 = new JPanel();private JframBank j
19、fb = null;public BTN1(String arg0) throws HeadlessException super(arg0);setSize(300, 200);t1=new JTextField(15);b1.setName("查询");btn1 = new JButton("查询余额");btn1.addActionListener(new B();btn2 = new JButton("退出");btn2.addActionListener(new B();b1.add(btn1);b1.add(btn2);b
20、1.add(t1);setContentPane(b1);this.setVisible(true);public JTextField getT1() return t1;class B implements ActionListener public void actionPerformed(ActionEvent arg0) Object o = arg0.getSource();if (o = btn1) Query query = new Query();query.query(jfb);if (o = btn2) jfb=new JframBank("XX银行欢迎登陆!&
21、quot;);jfb.setVisible(true);jfb.pack();setVisible(false);package com.action;import java.awt.HeadlessException;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.IOException;import javax.rmi.CORBA.Tie;import javax.swing.JButton;import javax.swing.JFrame;import javax
22、.swing.JPanel;import javax.swing.JTextField;import javax.swing.text.Position.Bias;import com.action.JframBank;import com.userland.Welcomeland;/* * 取款界面 * author Administrator * */public class BTN2 extends JFrameprivate JButton btn1,btn2;JTextField t1;JPanel b1=new JPanel();JframBank jfb=null;public
23、BTN2(String arg0) throws HeadlessException super(arg0);setSize(300, 200);b1.setName("取款");btn1 =new JButton("取款");btn1.addActionListener(new B();btn2 =new JButton("退出");btn2.addActionListener(new B();t1=new JTextField(15);t1.addActionListener(new B();b1.add(btn1);b1.add
24、(btn2);b1.add(t1);setContentPane(b1);this.setVisible(true);class B implements ActionListenerpublic void actionPerformed(ActionEvent arg0) Object o = arg0.getSource();if(o=btn1)/Withdraw withdraw=new Withdraw();try Withdraw.Withdrawl(); catch (IOException e) / TODO Auto-generated catch blocke.printSt
25、ackTrace();elsejfb=new JframBank("XX银行欢迎登陆!");jfb.setVisible(true);jfb.pack();setVisible(false);jfb.setVisible(true);package com.action;import java.awt.HeadlessException;import java.awt.event.ActionEvent;t.ActionListener;import javax.rmi.CORBA.Tie;import javax.swing.JButton;import javax.sw
26、ing.JFrame;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.text.Position.Bias;import com.action.JframBank;/* * 存款界面 * author Administrator * */public class BTN3 extends JFrameprivate JButton btn1,btn2;JTextField t1;JPanel b1=new JPanel();JframBank jfb=null;public BTN3(Stri
27、ng arg0) throws HeadlessException super(arg0);setSize(300, 200);b1.setName("存款");btn1 =new JButton("存款");btn1.addActionListener(new B();btn2 =new JButton("退出");btn2.addActionListener(new B();t1=new JTextField(15);t1.addActionListener(new B();b1.add(btn1);b1.add(btn2);b1
28、.add(t1);setContentPane(b1);this.setVisible(true);class B implements ActionListenerpublic void actionPerformed(ActionEvent arg0) Object o = arg0.getSource();if(o=btn1)Save save=new Save();save.save();elsejfb=new JframBank("XX银行欢迎登陆!");jfb.setVisible(true);jfb.pack();setVisible(false);jfb.s
29、etVisible(true);package com.action;import java.awt.HeadlessException;import java.awt.Label;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.IOException;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import
30、 javax.swing.JTextField;import com.action.JframBank;/* * 转账界面 * author Administrator * */public class BTN4 extends JFrameprivate JLabel l1,l2;private JButton btn1,btn2;JTextField t1,t2;JPanel b1=new JPanel();JframBank jfb=null;public BTN4(String arg0) throws HeadlessException super(arg0);setSize(150
31、, 200);b1.setName("转账");btn1 =new JButton("转账");btn1.addActionListener(new B();btn2 =new JButton("退出");btn2.addActionListener(new B();l1=new JLabel("转账账号:");t1=new JTextField(10);t1.addActionListener(new B();l2=new JLabel("转账金额:");t2=new JTextField(1
32、0);t2.addActionListener(new B();b1.add(btn1);b1.add(btn2);b1.add(l1);b1.add(t1);b1.add(l2);b1.add(t2);setContentPane(b1);this.setVisible(true);class B implements ActionListenerpublic void actionPerformed(ActionEvent arg0) Object o = arg0.getSource();if(o=btn1)Transfer transfer = new Transfer();try t
33、ransfer.Tran(jfb); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();elsejfb=new JframBank("XX银行欢迎登陆!");jfb.setVisible(true);jfb.pack();setVisible(false);jfb.setVisible(true);package com.action;import java.io.BufferedReader;import java.io.BufferedWriter;import java
34、.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.io.InputStreamReader;import javax.swing.JTextField;/* * 查询 * author Administrator * */public class Query public void query(JframBank jframBank)try Buffe
35、redReader Ia=new BufferedReader(new InputStreamReader(new FileInputStream("1.txt");try String a=Ia.readLine();Ia.close();System.out.println(""+a);BTN1.t1.setText(a); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace(); catch (FileNotFoundException e) / TODO
36、 Auto-generated catch blocke.printStackTrace();package com.action;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.FileReader;import java.io.FileWriter;import java.io.IOExcep
37、tion;import java.io.InputStreamReader;import java.io.OutputStream;import java.io.OutputStreamWriter;/* * 存款 * author Administrator * */public class Save public void save()BufferedReader br = null;try InputStreamReader isr =new InputStreamReader(new FileInputStream("1.txt");BufferedReader i
38、a=new BufferedReader(isr);String a=ia.readLine();String s=JframBank.bt3.t1.getText();ia.close();int c = Integer.parseInt(a); /c数据信息对应a 原金额int d = Integer.parseInt(s); /d数据信息对应s存入金额if (d>0) int e=c+d;String f = String.valueOf(e);/int转换成stringSystem.out.println("你存入了:"+s+"元");Sy
39、stem.out.println("你的账户余额:"+f);OutputStreamWriter osw =new OutputStreamWriter(new FileOutputStream("1.txt");BufferedWriter bw =new BufferedWriter(osw);bw.write(f);bw.close();Savesuccess ss=new Savesuccess("");ss.setVisible(true);elseWithdraWerror w=new WithdraWerror(&quo
40、t;");w.setVisible(true); catch (FileNotFoundException e) / TODO Auto-generated catch blocke.printStackTrace(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();package com.action;import java.awt.HeadlessException;import java.awt.Label;import javax.swing.JFrame;import j
41、avax.swing.JPanel;public class Savesuccess extends JFrameprivate JPanel b1=new JPanel();Label label;public Savesuccess(String arg0) throws HeadlessException setSize(300,200);label=new Label("存款成功,请退出!");b1.add(label);setContentPane(b1);package com.action;import java.io.BufferedInputStream;
42、import java.io.BufferedOutputStream;import java.io.BufferedReader;import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.FileReader;import java.io.FileWriter;import java.io.Filt
43、erReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.Scanner;import javax.swing.JTextField;/* * 转账 * author Administrator * */public class Transfer public void Tran(JframBank jframBank) throws IOExceptionInputStreamReader isr =new InputStreamReader(new FileInputStrea
44、m("1.txt");BufferedReader Ia=new BufferedReader(isr);String a=Ia.readLine();Ia.close();String s=jframBank.bt4.t1.getText();/转账账户String b=jframBank.bt4.t2.getText();int d = Integer.parseInt(a);/d数据信息对应a 原金额int c = Integer.parseInt(b);/c对应为输入的金额 转账金额if (c>=0) if (d>c) int e=d-c;/剩余金额St
45、ring f = String.valueOf(e);/int转换成stringInputStreamReader isr2 =new InputStreamReader(new FileInputStream("2.txt");BufferedReader Ib=new BufferedReader(isr2);String g=Ib.readLine();int h = Integer.parseInt(g);/把转账账号的金额转成string类型h=h+c;String j = String.valueOf(h);FileWriter fw=new FileWrite
46、r("1.txt");fw.write(f);fw.flush();FileWriter fw1=new FileWriter("2.txt");fw1.write(j);fw1.flush();Ib.close();System.out.println("你转账:"+b);TransferSuccess ts=new TransferSuccess("");ts.setVisible(true);elseTransferError tr=new TransferError("");tr.set
47、Visible(true);elseWithdraWerror wi=new WithdraWerror("");wi.setVisible(true);package com.action;import java.awt.HeadlessException;import java.awt.Label;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.s
48、wing.JPanel;import com.action.JframBank.J;public class TransferError extends JFrameprivate JPanel b1=new JPanel();Label label;private JButton btn1;public TransferError(String arg0) throws HeadlessException setSize(300,200);label=new Label("存款成功,请退出!");b1.add(label);setContentPane(b1);packa
49、ge com.action;import java.awt.HeadlessException;import java.awt.Label;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;public class TransferSuccess extends JFrameprivate JPanel b1=new JPanel();Label label;private JButton btn1;public TransferSuccess(String arg0) throws HeadlessException setSize(300,200);label=new Label("转账成功,请退出!");b1.add(label);setContentPane(b1);package com.action;import java.io.BufferedReader;import java.io.FileInputStream;import java.io.FileWriter;import
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 河道城市供热系统改造合同
- 建筑安全净化施工合同
- 建筑工程测量合同样本
- 智能电网电力施工合同范本
- 酒店工程建造师招聘合同
- 保健医生岗位聘用合同
- 高速公路安全文明施工协议
- 非营利组织合同专用章管理规定
- 出售葵花合同范例
- 店铺定做礼品采购合同范例
- DB37-T 4253-2020 地热资源勘查技术规程
- 诸暨中学提前招生选拔考试数学试卷含答案
- 高压氧治疗-PPT课件
- 研究型课程(跨学科)项目学习设计与实施案例
- 西门子s7_200PLC基本指令
- 特殊学生成长档案记录(精选.)
- 高速公路安全封路施工标志标牌示意图
- 计算机科学前沿技术课心得体会
- 窗玻璃的可见光透射比.遮阳系数
- 监理工作程序流程图(共24页)
- 打印机租赁服务月考核表
评论
0/150
提交评论