《ATM机银行项目java图形界面》由会员分享,可在线阅读,更多相关《ATM机银行项目java图形界面(27页珍藏版)》请在人人文库网上搜索。
1、登陆package ;/* 欢迎界面* author Administrator*/public class Welcomeland extends JFrameJPanel 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 JB。
2、utton( 登陆 );(new MyActionListner();(btn1);(label);setContentPane(p1);public static void main(String args) Welcomeland myJframe = new Welcomeland(XX 银行欢迎登陆! );(true);class MyActionListner implements ActionListener Overridepublic void actionPerformed(ActionEvent arg0) Object o = ();if (o = btn1) jf=ne。
3、w JframUserLand(XX 银行欢迎登陆! );();setVisible(false);(true);package ;im登陆界面* 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(。
4、800, 600);p1 = new JPanel();Frame f = new Frame( 用户登录 );(new GridLayout(4, 2);btn2 = new JButton( 确认 );(new MyActionListner();t1 = new JTextField(输入用户名 , 15);t2 = new JPasswordField( 输入密码 , 15);(new Label( 用户名 :, );(t1);(new Label( 密码 :, );(t2);(btn2);setContentPane(p1);(true);class MyActionListner 。
5、implements ActionListener Overridepublic void actionPerformed(ActionEvent arg0) Object o = ();if (o = btn2) InputStreamReader isr;try isr = new InputStreamReader(new FileInputStream();BufferedReader Ia = new BufferedReader(isr);String a = ();String b = ();();if (JframUserLanJframBank jBank = new Jfr。
6、amBank(XX 银行欢迎登陆! );(true);();setVisible(false);(true); else JframUserLand jframUserLand = new JframUserLand(XX 银行欢迎登陆! );(true);();setVisible(false);(true); catch (FileNotFoundException e) / TODO Auto-generated catch block(); catch (IOException e) / TODO Auto-generated catch block();package ;impo* 。
7、主界面* author Administrator*/public class JframBank extends JFrame private BTN1 bt1 = 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。
8、 = new JPanel();btn1 = new JButton( 查询 );(new J();btn2 = new JButton( 取款 );(new J();btn3 = new JButton( 存钱 );(new J();btn4 = new JButton( 转账 );(new J();btn5 = new JButton( 退出 );(new J();(btn1);(btn2);(btn3);(btn4);(btn5);setContentPane(p1);(true);class J implements ActionListener public void actionP。
9、erformed(ActionEvent arg0) Object o = ();if (o = btn1) bt1 = new BTN1( 查询 );();setVisible(false);(true);if (o = btn2) bt2 = new BTN2( 取款 );();setVisible(false);(true);if (o = btn3) bt3 = new BTN3( 存款 );();setVisible(false);(true);if (o = btn4) bt4 = new BTN4( 转账 );();setVisible(false);(true);银行欢迎登陆!。
10、 );if (o = btn5) Welcomeland wel = new Welcomeland(XX(true);();setVisible(false);(true);public BTN1 getBt1() return bt1;package ;/* 查询界面* author Administrator*/public class BTN1 extends JFrame private JButton btn1, btn2;static JTextField t1;private JPanel b1 = new JPanel();private JframBank jfb = nu。
11、ll;public BTN1(String arg0) throws HeadlessException super(arg0);setSize(300, 200);t1=new JTextField(15);( 查询 );btn1 = new JButton( 查询余额 );(new B();btn2 = new JButton( 退出 );(new B();(btn1);(btn2);(t1);setContentPane(b1);(true);public JTextField getT1() return t1;class B implements ActionListener pub。
12、lic void actionPerformed(ActionEvent arg0) Object o = ();if (o = btn1) (jfb);银行欢迎登陆! );if (o = btn2) jfb=new JframBank(XX(true);();setVisible(false);package ;import ja/* 取款界面* author Administrator*/public class BTN2 extends JFrameprivate JButton btn1,btn2;JTextField t1;JPanel b1=new JPanel();JframBa。
13、nk jfb=null;public BTN2(String arg0) throws HeadlessException super(arg0);setSize(300, 200);( 取款 );btn1 =new JButton( 取款 );(new B();btn2 =new JButton( 退出 );(new B();t1=new JTextField(15);(new B();(btn1);(btn2);(t1);setContentPane(b1);(true);class B implements ActionListenerpublic void actionPerforme。
14、d(ActionEvent arg0) Object o = ();if(o=btn1)try (); catch (IOException e) / TODO Auto-generated catch block();elsejfb=new JframBank(XX 银行欢迎登陆! );(true);();setVisible(false);(true);package ;/* * 存款界面* author Administrator*/public class BTN3 extends JFrameprivate JButton btn1,btn2;JTextField t1;JPanel。
15、 b1=new JPanel();JframBank jfb=null;public BTN3(String arg0) throws HeadlessException super(arg0);setSize(300, 200);( 存款 );btn1 =new JButton( 存款 );(new B();btn2 =new JButton( 退出 );(new B();t1=new JTextField(15);(new B();(btn1);(btn2);(t1);setContentPane(b1);(true);class B implements ActionListenerpu。
16、blic void actionPerformed(ActionEvent arg0) Object o = ();if(o=btn1)Save save=new Save();();elsejfb=new JframBank(XX 银行欢迎登陆! );(true);();setVisible(false);(true);package ;* 转账界面*/public class BTN4 extends JFrameprivate JLabel l1,l2;private JButton btn1,btn2;JTextField t1,t2;JPanel b1=new JPanel();Jf。
17、ramBank jfb=null;public BTN4(String arg0) throws HeadlessException super(arg0);setSize(150, 200);( 转账 );btn1 =new JButton( 转账 );(new B();btn2 =new JButton( 退出 );(new B();l1=new JLabel( 转账账号: );t1=new JTextField(10);(new B();l2=new JLabel( 转账金额: );t2=new JTextField(10);(new B();(btn1);(btn2);(l1);(t1。
18、);(l2);(t2);setContentPane(b1);(true);class B implements ActionListenerpublic void actionPerformed(ActionEvent arg0) Object o = ();if(o=btn1)Transfer transfer = new Transfer();try (jfb); catch (IOException e) / TODO Auto-generated catch block();elsejfb=new JframBank(XX 银行欢迎登陆! );(true);();();setVisi。
19、ble(false);(true);package ;/* 查询* author Administrator*/public class Query public void query(JframBank jframBank) try InputStreamReader(newBufferedReader Ia=new BufferedReader(new FileInputStream();try String a=();(); catch (IOException e) / TODO Auto-generated catch block(); catch (FileNotFoundExce。
20、ption e) / TODO Auto-generated catch block();package ;/* 存款* author Administrator*/public class Save public void save() BufferedReader br = null;try InputStreamReaderisr=new InputStreamReader(newFileInputStream();BufferedReader ia=new BufferedReader(isr);String a=();();int c = (a); /c数据信息对应 a 原金额int。
21、 d = (s);/d 数据信息对应 s 存入金额if (d0) int e=c+d;String f = (e);/int 转换成 stringOutputStreamWriter osw =new OutputStreamWriter(newFileOutputStream();BufferedWriter bw =new BufferedWriter(osw);(f);();Savesuccess ss=new Savesuccess();(true);elseWithdraWerror w=new WithdraWerror();(true); catch (FileNotFoundE。
22、xception e) / TODO Auto-generated catch block catch (IOException e) / TODO Auto-generated catch block();package ;public class Savesuccess extends JFrameprivate JPanel b1=new JPanel();Label label;public Savesuccess(String arg0) throws HeadlessException setSize(300,200);label=new Label( 存款成功,请退出! );(l。
23、abel);setContentPane(b1);package ;/* 转账* author Administrator*/public class Transfer public void Tran(JframBank jframBank) throws IOExceptionInputStreamReader isr =new InputStreamReader(new FileInputStream();BufferedReader Ia=new BufferedReader(isr);String a=();();int d = (a); /d数据信息对应 a 原金额int c = 。
24、(b); /c对应为输入的金额 转账金额if (c=0) if (dc) int e=d-c; / 剩余金额String f = (e); /int 转换成 stringInputStreamReaderisr2 =new InputStreamReader(newFileInputStream();BufferedReader Ib=new BufferedReader(isr2);String g=();int h = (g); /把转账账号的金额转成 string 类型h=h+c;String j = (h);FileWriter fw=new FileWriter();(f);();F。
25、ileWriter fw1=new FileWriter();(j);();();TransferSuccess ts=new TransferSuccess();(true);elseTransferError tr=new TransferError();(true);elseWithdraWerror wi=new WithdraWerror();(true);package ;public class TransferError extends JFrameprivate JPanel b1=new JPanel();Label label;private JButton btn1;p。
26、ublic TransferError(String arg0) throws HeadlessException setSize(300,200);label=new Label( 存款成功,请退出! );(label);setContentPane(b1);package ;public class TransferSuccess extends JFrameprivate JPanel b1=new JPanel();Label label;private JButton btn1;public TransferSuccess(String arg0) throws HeadlessEx。
27、ception setSize(300,200);label=new Label( 转账成功,请退出! );(label);setContentPane(b1);package ;* 取款* author Administrator*/public class Withdraw public static void Withdrawl() throws IOExceptionInputStreamReader isr =newInputStreamReader(newFileInputStream();BufferedReader Ia=new BufferedReader(isr);Stri。
28、ng a=();();int c = (a); /c 数据信息对应 a 原金额int d=(s);/d 数据信息对应 b 取款金额();/ 判断输入的数是否为正数if (d0) int e=c-d;if (e=0) String f = (e);FileWriter fw2=new FileWriter();(f);();WithdrawSuccess wi=new WithdrawSuccess();(true);else TransferError t=new TransferError();(true);elseWithdraWerror w=new WithdraWerror();(t。
29、rue);package ;public class WithdraWerror extends JFrameprivate JPanel b1=new JPanel();Label label;public WithdraWerror(String arg0) throws HeadlessException setSize(300,200);label=new Label( 输入不合法,请退出重新输入! ); (label);setContentPane(b1);package ;public class WithdrawSuccess extends JFrameprivate JPanel b1=new JPanel();Label label;public WithdrawSuccess(String arg0) throws HeadlessException setSize(300,200);label=new Label( 取款成功,请退出! );(label);setContentPane(b1。