javaATM柜員機(jī)模擬程序1_第1頁
javaATM柜員機(jī)模擬程序1_第2頁
javaATM柜員機(jī)模擬程序1_第3頁
javaATM柜員機(jī)模擬程序1_第4頁
javaATM柜員機(jī)模擬程序1_第5頁
已閱讀5頁,還剩53頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

/課程論文現(xiàn)代軟件工程與實(shí)踐題目:ATM柜員機(jī)模擬程序?qū)W院(系):信息工程學(xué)院專業(yè)班級(jí):學(xué)生姓名:指導(dǎo)教師:2011年12月4日摘要通過設(shè)計(jì)ATM柜員模擬程序,加深自己對(duì)Java編程尤其是對(duì)Java圖形用戶界面編程的了解,將自己的學(xué)到的編程知識(shí)融會(huì)貫通,同時(shí)培養(yǎng)自身面向?qū)ο筌浖_發(fā)的思維,初步了解軟件開發(fā)的一般流程,提高用Java實(shí)際動(dòng)手能力并增強(qiáng)自己對(duì)面向?qū)ο蟮牧私?。通過這次編程設(shè)計(jì),加深了對(duì)Java圖形界面編程中各個(gè)模塊和組件的應(yīng)用了解,以與類和類之間的關(guān)系,界面排版的處理等。設(shè)計(jì)要求是,當(dāng)輸入給定的卡號(hào)和密碼(初始卡號(hào)和密碼為123456)時(shí),系統(tǒng)能登錄ATM柜員機(jī)系統(tǒng),用戶可以按照以下規(guī)則進(jìn)行(規(guī)則可以按照實(shí)際系統(tǒng)做需求):(1)查詢余額:初始余額為10000元。(2)ATM取款:每次取款金額為100的倍數(shù),總額不超過5000元,支取金額不允許透支。(3)ATM存款:不能出現(xiàn)負(fù)存款。(4)修改密碼:新密碼長度不小于6位,不允許出現(xiàn)6位完全相同的情況,只有舊密碼正確,新密碼符合要求,且兩次輸入相同的情況下才可以成功修改密碼。該程序設(shè)置了7個(gè)類,1個(gè)主類6個(gè)輔助類,6個(gè)輔助類都是內(nèi)部類的形式,輔助類包括五個(gè)實(shí)現(xiàn)ATM的功能,一個(gè)存放客戶資料,之所以用內(nèi)部類來實(shí)現(xiàn)是為了在各個(gè)界面轉(zhuǎn)換時(shí)不至于要?jiǎng)?chuàng)建多個(gè)對(duì)象,每一個(gè)輔助類的對(duì)象只要在主類中創(chuàng)建一次就可以在各個(gè)內(nèi)部類中引用。該程序利用的功能是利用Java事件監(jiān)聽技術(shù)來實(shí)現(xiàn)的,各種功能單獨(dú)的創(chuàng)建一個(gè)類來實(shí)現(xiàn),不會(huì)互相混淆,更加容易理清楚思路。設(shè)計(jì)的程序完美的實(shí)現(xiàn)了設(shè)計(jì)要求,具有查詢、取款、存款、修改密碼等功能。目錄摘要 I目錄 II1前言 11.1設(shè)計(jì)任務(wù) 11.1.1需求說明 11.2設(shè)計(jì)內(nèi)容 12程序要求 13算法分析 24流程圖 35程序源代碼與說明 45.1程序源代碼 45.2源代碼說明 215.2.1源代碼中自定義類的說明: 215.2.2源代碼中的事件監(jiān)聽器 226調(diào)試與運(yùn)行結(jié)果 237體會(huì) 298參考文獻(xiàn) 301前言1.1設(shè)計(jì)任務(wù)1.1.1需求說明隨著市場經(jīng)濟(jì)的繁榮發(fā)展,人們的物質(zhì)生活得到極大的提高,手中的剩余資金也日益增多。受傳統(tǒng)觀念影響,絕大多數(shù)人喜歡把資金投進(jìn)銀行,而在需要使用現(xiàn)金的時(shí)候再到銀行提取現(xiàn)金。這就導(dǎo)致銀行業(yè)務(wù)的急劇增加。雖然銀行網(wǎng)點(diǎn)越來越多,銀行的工作效率也隨著信息化有較明顯的增長,但是依舊不能滿足廣大用戶的需要。而一味的增加營業(yè)網(wǎng)點(diǎn),從理論上雖然能稍微的緩解銀行的壓力,但是治標(biāo)不治本,而且每增加一個(gè)網(wǎng)點(diǎn),不僅要付出昂貴的資金成本,還需要長期投入人力資本,成本非常之昂貴。這時(shí)候就迫切的需要一種自動(dòng)的,易于普與的,低成本的設(shè)備來解決這一問題。于是ATM機(jī)系統(tǒng)應(yīng)運(yùn)而生了。本文正是通過設(shè)計(jì)一個(gè)ATM模擬模擬程序來實(shí)現(xiàn)ATM機(jī)系統(tǒng)的基本功能,充分運(yùn)用自己所學(xué)的Java知識(shí)進(jìn)行設(shè)計(jì)編程。1.2設(shè)計(jì)內(nèi)容(1)程序要求(2)算法分析(3)流程圖(4)源程序(5)調(diào)試與運(yùn)行結(jié)果(6)體會(huì)2程序要求本ATM柜員機(jī)的主要功能如下所述:要求使用圖形用戶界面。當(dāng)輸入給定的卡號(hào)和密碼(初始卡號(hào)和密碼為123456)時(shí),系統(tǒng)能登錄ATM柜員機(jī)系統(tǒng),用戶可以按照以下規(guī)則進(jìn)行:查詢余額:初始余額為10000元。ATM取款:每次取款金額為100的倍數(shù),總額不超過5000元,支取金額不允許透支。ATM存款:不能出現(xiàn)負(fù)存款。修改密碼:新密碼長度不小于6位,不允許出現(xiàn)6位完全相同的情況,只有舊密碼正確,新密碼符合要求,且兩次輸入相同的情況下才可以成功修改密碼。3算法分析通過程序要求,我們可以清楚的知道本次設(shè)計(jì)的ATM柜員模擬程序需要實(shí)現(xiàn)四大功能,即查詢余額、取款、存款、修改密碼。初次之外,作為ATM系統(tǒng),還需要最基本的兩大功能,即登陸和退出。根據(jù)上述的功能分析,我們可以吧整個(gè)ATM系統(tǒng)分為登陸模塊、查詢模塊、取款模塊、存款模塊、修改密碼模塊。除此之外,還有在登陸系統(tǒng)后的功能選擇模塊,退出功能則鑲嵌在各個(gè)需要的模塊中。由于各個(gè)模塊的功能實(shí)現(xiàn)是通過界面顯示出來的,則程序設(shè)計(jì)又可以理解為幾大界面的設(shè)計(jì):登陸界面、主界面、查詢余額界面、取款界面、存款界面、修改密碼界面。除了幾大界面之外,還有系統(tǒng)的初始化,主要是初始卡號(hào)、密碼的設(shè)定等。在程序的大體框架確定之后,我們需要了解各個(gè)模塊所要實(shí)現(xiàn)和需要具有的功能。根據(jù)現(xiàn)有的銀行ATM系統(tǒng),我們可以很快就可以了解本次設(shè)計(jì)的ATM系統(tǒng)應(yīng)該具有的操作。(1)登陸界面用戶輸入正確的賬號(hào)和密碼就可以登錄到該系統(tǒng)的主界面中去,進(jìn)行相應(yīng)的操作:取款、存款、查詢、修改密碼。(2)主界面主界面包括查詢、存款、取款、修改密碼、退出的功能按鈕,按下相應(yīng)的按鈕,可以進(jìn)行相應(yīng)的操作。(3)查詢界面在主界面中按下查詢按鈕可以進(jìn)行查詢操作。通過查詢功能我們可以查詢賬戶的余額,在查詢過程中我們可以選擇取款的業(yè)務(wù),除此之外,查詢界面之中還有返回和退出的操作。返回的操作會(huì)使用戶回到主界面,退出的操作會(huì)使用戶直接回到登陸界面。(4)取款界面取款界面既可以通過主界面進(jìn)入,也可以通過查詢、存款等操作過程中的界面進(jìn)入。取款功能在對(duì)話框中輸入你想要取出的金額,但是次金額不可以比賬戶的余額大,且必須是100的整數(shù)倍,取款完畢,會(huì)彈出是否顯示余額的提示,選“是”的話就會(huì)進(jìn)入查詢界面,選“否”的話,則回到主界面。(5)存款界面在主界面按下存款按鈕可以進(jìn)行存款操作,在對(duì)話中輸入你需要存入的金額,所輸入的數(shù)字也要是100的整數(shù)倍,而且不可以是負(fù)數(shù)。存款完畢,會(huì)彈出是否顯示余額的提示,選“是”的話就會(huì)進(jìn)入查詢界面,選“否”的話,則回到主界面。(6)修改密碼選擇修改密碼按鈕可以進(jìn)行修改密碼房,但是要先輸入就密碼正確并且兩次輸入新密碼一致才可以修改密碼。修改完成后,會(huì)返回主界面。4流程圖圖1程序流程圖5程序源代碼與說明5.1程序源代碼importjavax.swing.*;importjavax.swing.JOptionPane;importjava.awt.event.*;publicclassATMmodel{Accountmyaccount=newAccount();Loadload=newLoad();MainFrameJmain=newMainFrame();Taketake=newTake();Inputinput=newInput();Displaydis=newDisplay();Setpwsetpw=newSetpw();publicATMmodel(){JOptionPane.showMessageDialog(null,"歡迎使用ATM柜員模擬系統(tǒng)"); }publicstaticvoidmain(String[]args){ATMmodelatm=newATMmodel();}/*創(chuàng)建賬戶*/classAccount{privateintcount=10000;//初始賬戶余額10000privateStringaccount="123456";//初始賬號(hào)privateStringpassword="123456";//初始密碼publicAccount(){}publicvoidsetpw(Stringpassword){this.password=password;}publicvoiddeccount(intmoney){count-=money;}publicvoidreccount(intmoney){count+=money; }publicintget(){returncount;}publicStringgetaccount(){//賬號(hào)returnaccount;}publicStringgetpw(){returnpassword; }}/* 主界面*/classMainFrameextendsJFrame{publicJButtonchecked;publicJButtoncunkuan;publicJButtonquit;publicJButtonqukuan;publicJButtonreset;publicMainFrame(){initComponents();this.setLocationRelativeTo(null);//this.setVisible(false);}/*控件初始化*/ privatevoidinitComponents(){cunkuan=newJButton();qukuan=newJButton();checked=newJButton();reset=newJButton();quit=newJButton(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);setTitle("ATM柜員模擬程序"); setName("mianframe");setResizable(false);cunkuan.setText("存款");cunkuan.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevt){cunkuanActionPerformed(evt);}}); qukuan.setText("取款");qukuan.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevt){qukuanActionPerformed(evt);}}); checked.setText("查詢");checked.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevt){checkedActionPerformed(evt);}}); reset.setText("修改密碼");reset.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevt){resetActionPerformed(evt);}}); quit.setText("退出");quit.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevt){quitActionPerformed(evt);}}); GroupLayoutlayout=newGroupLayout(getContentPane());//GroupLayout它將組件按層次分組,以決定它們?cè)贑ontainer中的位置getContentPane().setLayout(layout);layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(cunkuan).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,105,Short.MAX_VALUE).addComponent(reset)).addGroup(javax.swing.GroupLayout.Alignment.TRAILING,layout.createSequentialGroup().addComponent(qukuan).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,143,Short.MAX_VALUE).addComponent(quit)).addComponent(checked)).addContainerGap()));layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(46,46,46).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(cunkuan).addComponent(reset)).addGap(51,51,51).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(quit).addComponent(qukuan)).addGap(57,57,57).addComponent(checked).addGap(39,39,39)));pack();}privatevoidquitActionPerformed(ActionEventevt){ load.setVisible(true);this.setVisible(false);}privatevoidresetActionPerformed(ActionEventevt){ setpw.setVisible(true); this.setVisible(false); }privatevoidcheckedActionPerformed(ActionEventevt){dis.setVisible(true);this.setVisible(false);}privatevoidqukuanActionPerformed(ActionEventevt){take.setVisible(true);this.setVisible(false);}privatevoidcunkuanActionPerformed(ActionEventevt){ input.setVisible(true); this.setVisible(false);}}/*登錄界面*/classLoadextendsJFrame{ publicJPasswordFieldJpassword;publicJTextFieldaccountnum;publicJButtoncommit;privateJLabeljL1;privateJLabeljL2;publicLoad(){initComponents();this.setLocationRelativeTo(null);this.setVisible(true);} privatevoidinitComponents(){jL1=newJLabel();jL2=newJLabel();accountnum=newJTextField();commit=newJButton();Jpassword=newJPasswordField();setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);setTitle("ATM柜員模擬程序");setResizable(false);jL1.setText("賬號(hào):");jL2.setText("密碼:");commit.setText("確定");commit.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){commitActionPerformed(evt);}});javax.swing.GroupLayoutlayout=newjavax.swing.GroupLayout(getContentPane());getContentPane().setLayout(layout);layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap(50,Short.MAX_VALUE).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jL1).addComponent(jL2)).addGap(31,31,31).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,false).addComponent(Jpassword).addComponent(accountnum,javax.swing.GroupLayout.DEFAULT_SIZE,143,Short.MAX_VALUE))).addGroup(layout.createSequentialGroup().addGap(122,122,122).addComponent(commit))).addContainerGap(72,Short.MAX_VALUE)));layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(85,85,85).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(accountnum,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jL1)).addGap(41,41,41).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jL2).addComponent(Jpassword,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,72,Short.MAX_VALUE).addComponent(commit).addGap(64,64,64)));pack();}privatevoidcommitActionPerformed(ActionEventevt){ if(accountnum.getText().equals(myaccount.getaccount())&&Jpassword.getText().equals(myaccount.getpw())) { Jmain.setVisible(true); this.setVisible(false); accountnum.setText(""); Jpassword.setText(""); } else{ JOptionPane.showMessageDialog(null,"密碼與賬戶不匹配,請(qǐng)重新輸入","出錯(cuò)提示",1); accountnum.setText(""); Jpassword.setText(""); }}}/*取款界面*/classTakeextendsJFrame{ publicJButtonback;publicJButtonclear;publicJButtoncommit;privateJLabeljL1;publicJTextFieldjT1;publicJButtonquit; Stringstr="";publicTake(){initComponents();this.setLocationRelativeTo(null);this.setVisible(false);}privatevoidinitComponents(){jL1=newJLabel();jT1=newJTextField();commit=newJButton();back=newJButton();quit=newJButton();clear=newJButton();setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);jL1.setText("取款金額:");commit.setText("確定");commit.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevt){commitActionPerformed(evt);}});back.setText("返回");back.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevt){backActionPerformed(evt);}});quit.setText("退出");quit.addActionListener(newActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){quitActionPerformed(evt);}});clear.setText("清除");clear.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevt){clearActionPerformed(evt);}});javax.swing.GroupLayoutlayout=newjavax.swing.GroupLayout(getContentPane());getContentPane().setLayout(layout);layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(41,41,41).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jL1).addGap(33,33,33).addComponent(jT1,javax.swing.GroupLayout.PREFERRED_SIZE,174,javax.swing.GroupLayout.PREFERRED_SIZE)).addGroup(layout.createSequentialGroup().addComponent(clear).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,147,Short.MAX_VALUE).addComponent(quit)).addGroup(layout.createSequentialGroup().addComponent(commit).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,147,Short.MAX_VALUE).addComponent(back))).addContainerGap(69,javax.swing.GroupLayout.PREFERRED_SIZE)));layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(103,103,103).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jL1).addComponent(jT1,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(61,61,61).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(commit).addComponent(back)).addGap(29,29,29).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(clear).addComponent(quit)).addContainerGap(65,Short.MAX_VALUE)));pack();}privatevoidclearActionPerformed(ActionEventevt){ str="";jT1.setText(str);}privatevoidquitActionPerformed(ActionEventevt){ load.setVisible(true); this.setVisible(false); }privatevoidbackActionPerformed(ActionEventevt){ Jmain.setVisible(true); this.setVisible(false);}privatevoidcommitActionPerformed(ActionEventevt){ if(Integer.parseInt(jT1.getText())>0&&Integer.parseInt(jT1.getText())%100==0&&Integer.parseInt(jT1.getText())<=5000){myaccount.deccount(Integer.parseInt(jT1.getText()));intresult=javax.swing.JOptionPane.showConfirmDialog(null,"是否顯示余額?","",javax.swing.JOptionPane.YES_NO_OPTION,javax.swing.JOptionPane.QUESTION_MESSAGE);if(result==javax.swing.JOptionPane.YES_OPTION){dis.set(String.valueOf(myaccount.get()));str=""; jT1.setText(str);dis.setVisible(true);this.setVisible(false);}else{Jmain.setVisible(true);this.setVisible(false);}}else{JOptionPane.showMessageDialog(null,"取款金額不能為負(fù)數(shù)"+"\n取款金額不能為0"+"\n取款金額必須是100的倍數(shù)"+"\n金額一次不能超過5000"+"\n請(qǐng)重新輸入你要取的金額數(shù)","出錯(cuò)提示",1);str="";jT1.setText(str);}}}/*存款界面*/classInputextendsJFrame{ privateJButtonclear;privateJButtoncommit;privateJLabeljL1;privateJTextFieldjT1;Stringstr="";publicInput(){initComponents();this.setLocationRelativeTo(null);this.setResizable(false);this.setVisible(false);}privatevoidinitComponents(){jL1=newJLabel();jT1=newJTextField();commit=newJButton();clear=newJButton();setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);jL1.setText("存款金額:");commit.setText("確認(rèn)");commit.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevt){commitActionPerformed(evt);}});clear.setText("清除");clear.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){clearActionPerformed(evt);}});javax.swing.GroupLayoutlayout=newjavax.swing.GroupLayout(getContentPane());getContentPane().setLayout(layout);layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(47,47,47).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(12,12,12).addComponent(commit).addGap(111,111,111).addComponent(clear)).addGroup(layout.createSequentialGroup().addComponent(jL1).addGap(27,27,27).addComponent(jT1,javax.swing.GroupLayout.PREFERRED_SIZE,151,javax.swing.GroupLayout.PREFERRED_SIZE))).addContainerGap(50,Short.MAX_VALUE)));layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(88,88,88).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jL1).addComponent(jT1,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(87,87,87).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(clear).addComponent(commit)).addContainerGap(88,Short.MAX_VALUE)));pack();}//</editor-fold>privatevoidclearActionPerformed(ActionEventevt){str="";jT1.setText(str);}privatevoidcommitActionPerformed(java.awt.event.ActionEventevt){ if(Integer.parseInt(jT1.getText())%100==0) { inta=Integer.parseInt(jT1.getText()); if(a<0) JOptionPane.showMessageDialog(null,"存款不能為負(fù)數(shù)","出錯(cuò)",1); else myaccount.reccount(a); dis.set(String.valueOf(myaccount.get())); intresult=javax.swing.JOptionPane.showConfirmDialog(null,"是否顯示余額?","",javax.swing.JOptionPane.YES_NO_OPTION,javax.swing.JOptionPane.QUESTION_MESSAGE);if(result==javax.swing.JOptionPane.YES_OPTION){str=""; jT1.setText(str);dis.setVisible(true);this.setVisible(false);}else{Jmain.setVisible(true);this.setVisible(false);} } else { JOptionPane.showMessageDialog(null,"存款金額必須為100的整數(shù)倍!"+"\n請(qǐng)確認(rèn)你的金額","出錯(cuò)提示",1); jT1.setText(""); }}}/*顯示余額界面*/classDisplayextendsJFrame{ publicJButtonback;privateJLabeljL1;publicJTextFieldjT1;publicJButtonquit;publicJButtonqukuan;publicDisplay(){initComponents();jT1.setText(String.valueOf(myaccount.get()));this.setLocationRelativeTo(null);this.setVisible(false);}publicvoidset(Stringstr){jT1.setText(str);}privatevoidinitComponents(){jL1=newJLabel();jT1=newJTextField();quit=newJButton();back=newJButton();qukuan=newJButton();setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);jL1.setText("您的余額為:");jT1.setEditable(false);quit.setText("退出");quit.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){quitActionPerformed(evt);}});back.setText("返回");back.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){backActionPerformed(evt);}});qukuan.setText("取款");qukuan.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){qukuanActionPerformed(evt);}});javax.swing.GroupLayoutlayout=newjavax.swing.GroupLayout(getContentPane());getContentPane().setLayout(layout);layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(27,27,27).addComponent(jL1).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE).addComponent(jT1,javax.swing.GroupLayout.PREFERRED_SIZE,143,javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(36,Short.MAX_VALUE)).addGroup(javax.swing.GroupLayout.Alignment.TRAILING,layout.createSequentialGroup().addContainerGap(215,Short.MAX_VALUE).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(back).addComponent(qukuan).addComponent(quit)).addContainerGap()));layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(93,93,93).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jL1).addComponent(jT1,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(54,54,54).addComponent(qukuan).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(back).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(quit).addContainerGap()));pack();}privatevoidqukuanActionPerformed(ActionEventevt){take.setVisible(true);this.setVisible(false);}privatevoidquitActionPerformed(ActionEventevt){ load.setVisible(true); this.setVisible(false);}privatevoidbackActionPerformed(ActionEventevt){ Jmain.setVisible(true); this.setVisible(false);}}/**修改密碼*/classSetpwextendsJFrame{publicJButtoncommit;publicJLabelcommitpw;publicJPasswordFieldjPwcommit;publicJPasswordFieldjPwnew;publicJPasswordFieldjPwold;publicJLabelnewpw;publicJLabeloldpw;publicJButtonquit;publicSetpw(){initComponents();this.setResizable(false);this.setLocationRelativeTo(null);//this.setVisible(false);}privatevoidinitComponents(){oldpw=newJLabel();newpw=newJLabel();commitpw=newJLabel();jPwold=newJPasswordField();jPwnew=newJPasswordField();jPwcommit=newJPasswordField();commit=newjavax.swing.JButton();quit=newjavax.swing.JButton();setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);oldpw.setText("舊密碼:");newpw.setText("新密碼:");commitpw.setText("確認(rèn)密碼:");commit.setText("確認(rèn)");commit.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){commitActionPerformed(evt);}});quit.setText("退出");quit.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){quitActionPerformed(evt);}});javax.swing.GroupLayoutlayout=newjavax.swing.GroupLayout(getContentPane());getContentPane().setLayout(layout);layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(46,46,46).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(oldpw).addComponent(newpw).addComponent(commitpw)).addGap(25,25,25).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,false).addGroup(layout.createSequentialGroup().addComponent(commit).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE).addComponent(quit)).addComponent(jPwnew,javax.swing.GroupLayout.DEFAULT_SIZE,180,Short.MAX_VALUE).addComponent(jPwold).addComponent(jPwcommit)).addContainerGap(48,Short.MAX_VALUE)));layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(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)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論