Bank account gui

Bank account gui

Add event handling to the AccountUI class which will allow you to:
1.  Create new account, when the ââ?¬Ë?Createââ?¬â?¢ button is pressed
a)  Make sure the user has entered an ID and the starting balance
b)  Create an account using the Account class constructor
c)  Update the ââ?¬Ë?Current Balanceââ?¬Â? Text field in the Transaction report section
d)  Update the ââ?¬Ë?Account Date Createdââ?¬â?¢ Text Field
e)  Hint: declare a global class variable of the type Account so it could be used in the AccountUI inner classes (ActionListener classes).
2.  Execute a ââ?¬Ë?Depositââ?¬â?¢ or ââ?¬Ë?Withdrawalââ?¬â?¢ when the ââ?¬Ë?Executeââ?¬â?¢ button is pressed
a)  Use the Account correct method for the specific transaction
b)  Make sure that an amount is entered and one of the Radio buttons is selected.
c)  Update the ââ?¬Ë?Current Balanceââ?¬Â? Text field in the Transaction report section
d)  Add the transaction to the list of transactions defined in the Account class
3.  Show all transactions in the TextArea when the ââ?¬Å?Reportââ?¬Â? button is pressed
a)  Get the list of transactions using the getTrasactions() method of the class Account.
b)  For each transactions print: date of transaction, type of transaction,  amount of transaction and balance after transaction execution.
c)  All of the methods are provided by the interface Transaction.
4.  Add the interface transaction to your project 
5.  Add the inner class ââ?¬Å?TransactionObjectââ?¬Â? in the Account class.
6.  Add the object transactionList to the Account class  as follow:
a)  List<Transaction>  transactionList = new ArrayList< Transaction>();

See the figure below.
View Answers

December 4, 2012 at 11:01 AM

Here is an example of BankAccount using swing components which allow the user to withdraw and deposit amount and display the current balance.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Account extends Frame {
Label lab=new Label(" ");
Label lab1=new Label(" ");
TextField t[]=new TextField [4];
Label l[]=new Label [4];
Button but=new Button("Create Account");
Button but1=new Button("Test Account");
BankAccount b;
Account(){
addWindowListener(new NewWindowAdapter());
setLayout(new GridLayout(2,0));
Panel p=new Panel();
Panel p1=new Panel();
p.setLayout(new GridLayout(5,2));
p.setBackground(Color.pink);
p1.add(lab1);
p1.add(lab);
l[0]=new Label("Enter Your Account Number");
l[1]=new Label("Enter Your Initial Balance");
l[2]=new Label("Deposit Amount");
l[3]=new Label("Withdraw Amount");
for(int i=0;i<4;i++){
t[i]=new TextField(10);
p.add(l[i]);
p.add(t[i]);
}
p.add(but);
p.add(but1);
but1.setVisible(false);
l[2].setVisible(false);
l[3].setVisible(false);
t[2].setVisible(false);
t[3].setVisible(false);
add(p);
add(p1);
p1.setBackground(Color.pink);
but.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String des=JOptionPane.showInputDialog(null,"Deposit or Withdraw");
if(des.equals("Deposit")){
b=new BankAccount(Integer.parseInt(t[0].getText()),Integer.parseInt(t[1].getText()));
but1.setVisible(true);
l[2].setVisible(true);
l[3].setVisible(false);
t[2].setVisible(true);
t[3].setVisible(false);
but.setVisible(false);
l[0].setVisible(false);
l[1].setVisible(false);
t[0].setVisible(false);
t[1].setVisible(false);
lab1.setText("Account : "+b.accnum+", Current Balance : "+b.amount);
but1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
lab.setText(testAccount1(Integer.parseInt(t[2].getText())));
lab1.setText("Account : "+b.accnum+", Current Balance : "+b.amount);
}
});
}
else if(des.equals("Withdraw")){
b=new BankAccount(Integer.parseInt(t[0].getText()),Integer.parseInt(t[1].getText()));
but1.setVisible(true);
l[2].setVisible(false);
l[3].setVisible(true);
t[2].setVisible(false);
t[3].setVisible(true);
but.setVisible(false);
l[0].setVisible(false);
l[1].setVisible(false);
t[0].setVisible(false);
t[1].setVisible(false);
lab1.setText("Account : "+b.accnum+", Current Balance : "+b.amount);
but1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
lab.setText(testAccount2(Integer.parseInt(t[3].getText())));
lab1.setText("Account : "+b.accnum+", Current Balance : "+b.amount);
}
});
}
}
});
}
String testAccount1(int d_amt){
String msg;
b.deposit(d_amt);
msg="Transaction Succesful";
return msg;
}
String testAccount2(int w_amt){
String msg;
msg="Transaction Succesful";
try{
b.withdraw(w_amt);
}catch(FundsInsufficientException fe){
fe=new FundsInsufficientException(b.amount,w_amt);
msg=String.valueOf(fe);
}
return msg;
}
public static void main(String arg[]){
Account at=new Account ();
at.setTitle("Bank Account System");
at.setSize(500,300);
at.setVisible(true);
}
}
class NewWindowAdapter extends WindowAdapter{
public void windowClosing(WindowEvent we){
System.exit(0);
}
}

December 4, 2012 at 11:02 AM

continue..

class BankAccount{
int accnum;
int amount;
BankAccount(int num,int amt){
accnum=num;
amount=amt;
}
public void deposit(int amt){
amount=amount+amt;
}
public void withdraw(int amt) throws FundsInsufficientException{
if(amt>amount)
throw new FundsInsufficientException(amount,amt);
else
amount=amount-amt;
}
}
class FundsInsufficientException extends Exception{
int balance;
int withdraw_amount;
FundsInsufficientException(int bal,int w_amt){
balance=bal;
withdraw_amount=w_amt;
}
public String toString(){
return "Your withdraw amount ("+withdraw_amount+") is more than the balance ("+balance+"). No withdrawal was recorded.";
}
}

For more information, visit the following link:

http://www.roseindia.net/tutorial/java/core/bankAccountApplication.html









Related Tutorials/Questions & Answers:
bank account gui
bank account gui  Add event handling to the AccountUI class which will allow you to: 1.Create new account, when the â??Createâ?? button is pressed...[]){ Account at=new Account (); at.setTitle("Bank Account System"); at.setSize(500,300
Bank account gui
Bank account gui  Add event handling to the AccountUI class which will allow you to: 1. Create new account, when the ââ?¬Ë?Createââ?¬â?¢ button... static void main(String arg[]){ Account at=new Account (); at.setTitle("Bank Account
Advertisements
validate bank account number
validate bank account number  how to validate bank account number in jsp
validate bank account number
validate bank account number  how to validate bank account number in jsp
how to generate bank account number?
how to generate bank account number?  how to generate account number?or format or rules for bank account number
Bank account manangement - Java Beginners
Bank account manangement  Assume that the bank maintains two kinds of accounts for its customers, one called savings account and the other current account. The savings account provides compound interest and withdrawal facilities
ModuleNotFoundError: No module named 'bank-account-validator'
ModuleNotFoundError: No module named 'bank-account-validator'  Hi...: No module named 'bank-account-validator' How to remove the ModuleNotFoundError: No module named 'bank-account-validator' error? Thanks   Hi
ModuleNotFoundError: No module named 'trytonar_account_bank_ar'
ModuleNotFoundError: No module named 'trytonar_account_bank_ar'  Hi...: No module named 'trytonar_account_bank_ar' How to remove the ModuleNotFoundError: No module named 'trytonar_account_bank_ar' error? Thanks  
ModuleNotFoundError: No module named 'bank-account-validator'
ModuleNotFoundError: No module named 'bank-account-validator'  Hi...: No module named 'bank-account-validator' How to remove the ModuleNotFoundError: No module named 'bank-account-validator' error? Thanks   Hi
Java Bank Account Application
Java Bank Account Application Here we have created a Bank Account Application... to enter all the required information like, name, account number, account type...); System.out.println("Account No:" + accNo); System.out.println("Balance:" + bal
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-reconcile-hook'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-reconcile-hook...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-reconcile-hook' How... odoo10-addon-account-bank-reconcile-hook After the installation of odoo10-addon
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-camt'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import...;odoo10-addon-account-bank-statement-import-camt' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-camt-details'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement... 'odoo10-addon-account-bank-statement-import-camt-details' error
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-fr-cfonb'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...;odoo10-addon-account-bank-statement-import-fr-cfonb' error? Thanks  
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-move-line'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...;odoo10-addon-account-bank-statement-import-move-line' error? Thanks
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-mt940-base'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement... 'odoo10-addon-account-bank-statement-import-mt940-base' error? Thanks
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-ofx'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import...-account-bank-statement-import-ofx' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-qif'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import...-account-bank-statement-import-qif' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-save-file'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...;odoo10-addon-account-bank-statement-import-save-file' error? Thanks
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-line-reconciliation'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-line...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement... 'odoo10-addon-account-bank-statement-line-reconciliation' error
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-reconcile-hook'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-reconcile-hook...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-reconcile-hook' How... odoo10-addon-account-bank-reconcile-hook After the installation of odoo10-addon
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-camt'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import...;odoo10-addon-account-bank-statement-import-camt' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-camt-details'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement... 'odoo10-addon-account-bank-statement-import-camt-details' error
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-coda'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import...;odoo10-addon-account-bank-statement-import-coda' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-fr-cfonb'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...;odoo10-addon-account-bank-statement-import-fr-cfonb' error? Thanks  
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-move-line'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...;odoo10-addon-account-bank-statement-import-move-line' error? Thanks
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-mt940-base'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement... 'odoo10-addon-account-bank-statement-import-mt940-base' error? Thanks
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-ofx'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import...-account-bank-statement-import-ofx' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-qif'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import...-account-bank-statement-import-qif' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-import-save-file'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement...;odoo10-addon-account-bank-statement-import-save-file' error? Thanks
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-line-reconciliation'
ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement-line...: ModuleNotFoundError: No module named 'odoo10-addon-account-bank-statement... 'odoo10-addon-account-bank-statement-line-reconciliation' error
ModuleNotFoundError: No module named 'odoo10-addon-account-skip-bank-reconciliation'
ModuleNotFoundError: No module named 'odoo10-addon-account-skip-bank...: ModuleNotFoundError: No module named 'odoo10-addon-account-skip-bank-reconciliation...-account-skip-bank-reconciliation' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-l10n-es-account-bank-statement-import-n43'
ModuleNotFoundError: No module named 'odoo10-addon-l10n-es-account-bank...: ModuleNotFoundError: No module named 'odoo10-addon-l10n-es-account-bank... 'odoo10-addon-l10n-es-account-bank-statement-import-n43' error? Thanks
ModuleNotFoundError: No module named 'odoo10-addon-l10n-es-account-bank-statement-import-n43'
ModuleNotFoundError: No module named 'odoo10-addon-l10n-es-account-bank...: ModuleNotFoundError: No module named 'odoo10-addon-l10n-es-account-bank... 'odoo10-addon-l10n-es-account-bank-statement-import-n43' error? Thanks
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import-camt-oca'
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement...;odoo11-addon-account-bank-statement-import-camt-oca' error? Thanks  
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import-camt-oca'
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement...;odoo11-addon-account-bank-statement-import-camt-oca' error? Thanks  
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import-coda'
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import...;odoo11-addon-account-bank-statement-import-coda' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import-move-line'
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement...;odoo11-addon-account-bank-statement-import-move-line' error? Thanks
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import-mt940-base'
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement... 'odoo11-addon-account-bank-statement-import-mt940-base' error? Thanks
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import-mt940-pl-raiffeisen'
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement... error: ModuleNotFoundError: No module named 'odoo11-addon-account-bank...: No module named 'odoo11-addon-account-bank-statement-import-mt940-pl
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import-ofx'
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import...-account-bank-statement-import-ofx' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import-paypal'
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import...;odoo11-addon-account-bank-statement-import-paypal' error? Thanks   
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import-qif'
ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo11-addon-account-bank-statement-import...-account-bank-statement-import-qif' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo11-addon-account-skip-bank-reconciliation'
ModuleNotFoundError: No module named 'odoo11-addon-account-skip-bank...: ModuleNotFoundError: No module named 'odoo11-addon-account-skip-bank-reconciliation...-account-skip-bank-reconciliation' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo11-addon-account-skip-bank-reconciliation'
ModuleNotFoundError: No module named 'odoo11-addon-account-skip-bank...: ModuleNotFoundError: No module named 'odoo11-addon-account-skip-bank-reconciliation...-account-skip-bank-reconciliation' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo11-addon-l10n-es-account-bank-statement-import-n43'
ModuleNotFoundError: No module named 'odoo11-addon-l10n-es-account-bank...: ModuleNotFoundError: No module named 'odoo11-addon-l10n-es-account-bank... 'odoo11-addon-l10n-es-account-bank-statement-import-n43' error? Thanks
ModuleNotFoundError: No module named 'odoo11-addon-l10n-ro-account-bank-statement-import-mt940-brd'
ModuleNotFoundError: No module named 'odoo11-addon-l10n-ro-account-bank...: No module named 'odoo11-addon-l10n-ro-account-bank-statement-import-mt940-brd'... to install padas library. You can install odoo11-addon-l10n-ro-account-bank
ModuleNotFoundError: No module named 'odoo12-addon-account-bank-statement-import-camt-oca'
ModuleNotFoundError: No module named 'odoo12-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo12-addon-account-bank-statement...;odoo12-addon-account-bank-statement-import-camt-oca' error? Thanks  
ModuleNotFoundError: No module named 'odoo12-addon-account-bank-statement-import-coda'
ModuleNotFoundError: No module named 'odoo12-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo12-addon-account-bank-statement-import...;odoo12-addon-account-bank-statement-import-coda' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo12-addon-account-bank-statement-import-fr-cfonb'
ModuleNotFoundError: No module named 'odoo12-addon-account-bank-statement...: ModuleNotFoundError: No module named 'odoo12-addon-account-bank-statement...;odoo12-addon-account-bank-statement-import-fr-cfonb' error? Thanks  

Ads