機(jī)銀行項(xiàng)目java圖形界面_第1頁
機(jī)銀行項(xiàng)目java圖形界面_第2頁
機(jī)銀行項(xiàng)目java圖形界面_第3頁
機(jī)銀行項(xiàng)目java圖形界面_第4頁
機(jī)銀行項(xiàng)目java圖形界面_第5頁
已閱讀5頁,還剩16頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

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("確認(rèn)");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("轉(zhuǎn)賬");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("轉(zhuǎn)賬");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;/* * 轉(zhuǎn)賬界面 * 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("轉(zhuǎn)賬");btn1 =new JButton("轉(zhuǎn)賬");btn1.addActionListener(new B();btn2 =new JButton("退出");btn2.addActionListener(new B();l1=new JLabel("轉(zhuǎn)賬賬號(hào):");t1=new JTextField(10);t1.addActionListener(new B();l2=new JLabel("轉(zhuǎn)賬金額:");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數(shù)據(jù)信息對(duì)應(yīng)a 原金額int d = Integer.parseInt(s); /d數(shù)據(jù)信息對(duì)應(yīng)s存入金額if (d>0) int e=c+d;String f = String.valueOf(e);/int轉(zhuǎn)換成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;/* * 轉(zhuǎn)賬 * 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();/轉(zhuǎn)賬賬戶String b=jframBank.bt4.t2.getText();int d = Integer.parseInt(a);/d數(shù)據(jù)信息對(duì)應(yīng)a 原金額int c = Integer.parseInt(b);/c對(duì)應(yīng)為輸入的金額 轉(zhuǎn)賬金額if (c>=0) if (d>c) int e=d-c;/剩余金額St

45、ring f = String.valueOf(e);/int轉(zhuǎn)換成stringInputStreamReader isr2 =new InputStreamReader(new FileInputStream("2.txt");BufferedReader Ib=new BufferedReader(isr2);String g=Ib.readLine();int h = Integer.parseInt(g);/把轉(zhuǎn)賬賬號(hào)的金額轉(zhuǎn)成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("你轉(zhuǎn)賬:"+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("轉(zhuǎn)賬成功,請退出!");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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論