*None of the buttons except create and clear work can someone help please , can anyone help me with the parts i have missing , the account and date test class work fine i just need the bank account GUI to work properly , here is a detailed explanation of what the program should do

Bank account GUI
Add a new Account
• Display information on an account neatly (search using account number). Having located an account one could update or delete it.
• Display all accounts held by a customer, one at a time (search using name). You could press next to see the next account for that person. Having located a particular account one could update or delete it.
• Delete an account entirely
• Update the account information
• Add monthly interest to all accounts.
• Print information for all accounts neatly, with appropriate headers, to a tab separated file, readable by a spreadsheet such as Excel or OpenOffice Calc.
• Exit the system
*/


/////account class\\\\\\\

Help with Code Tags

Java Syntax (Toggle Plain Text)
public class Account {
  // Instance variable 
  private double balance;
 
  String acctNumber ; 
 
   String dateOpened;
   String custID ; 
   int amountInArray;
 
  // Constructor 1 (for initial deposit accounts)
  public Account(String acctNum , double bal , String date , String custid) {
           acctNumber = acctNum;
           balance = bal ; 
           date = dateOpened ; 
           custID = custid ; 
  }
 
 
 //get the account number
 public String getacctNumber() {
    return acctNumber;
  }
 
 
   //get the account number
 public String getcustid() {
    return custID;
  }
 
  //get account balance
  public double getBalance() {
    return balance;
  }
 
    public String getacctDate() {
    return dateOpened;
  }
   //close account
 
}

////////date test class\\\\\\\\
Help with Code Tags
Java Syntax (Toggle Plain Text)
import java.text.SimpleDateFormat;
import java.text.ParseException;
 
public class DateTest {
 
  public boolean isValidDate(String inDate) {
 
    if (inDate == null)
      return false;
 
    //set the format to use as a constructor argument
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
 
    if (inDate.trim().length() != dateFormat.toPattern().length())
      return false;
 
    dateFormat.setLenient(false);
 
    try {
      //parse the inDate parameter
      dateFormat.parse(inDate.trim());
    }
    catch (ParseException pe) {
      return false;
    }
    return true;
 
 
  }
 
 
}

//////////////Bank account\\\\\\\\\\\\\\\\
Help with Code Tags
Java Syntax (Toggle Plain Text)
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import javax.swing.*;
import javax.swing.border.*;
import java.util.Arrays;
import java.io.*;
 
public class BankAccount extends JFrame {
 
    // Make these variables publicly available
 
 
    String file =  ("THUS.txt");
 
    public static String acctNumber ;
    public static String  custid , acctDateOpened;
    public static double balance ;
 
    boolean valid1, valid2, valid3, valid4, valid5, valid6, valid7 ;
 
    int i = 0; 
    Account [] account = new Account [i]; 
 
 
 
 
 
    // Setup Arrays for each account
 
 
    // JPanel for user inputs
    private JPanel inputDetailJPanel;
 
 
    // JLabel and Jtext field for custID
    private JTextField acctDateOpenedJTextField;
    private JLabel acctDateOpenedJLabel;
 
    // JLabel and Jtext field for custID
    private JTextField custidJTextField;
    private JLabel custidJLabel;
 
    // JLabel and JTextField for account number
    private JLabel acctNumberJLabel;
    private JTextField acctNumberJTextField;
 
    // JLabel and JTextField for balance
    private JLabel balanceJLabel;
    private JTextField balanceJTextField;
 
 
    // JButton to create account
    private JButton CreateAccountJButton;
 
    //JButton for update
    private JButton updateJButton ; 
 
    //JButton for update
    private JButton interestJButton ; 
 
 
    //JButton to clear account 
    private JButton clearJButton ; 
 
 
 
    // JButton to delete account
    private JButton DeleteAccountJButton;
 
    // initialise display account 
    private JButton displayAccountJButton ; 
 
 
    // JLabel and JTextArea to display account details
    private JLabel displayJLabel;
    private JTextArea displayJTextArea;
 
 
 
 
 
    // constructor
    public BankAccount() {
        createUserInterface();
    }
 
    // create and position GUI components; register event handlers
    private void createUserInterface() {
        // get content pane for attaching GUI components
        Container contentPane = getContentPane();
 
        // enable explicit positioning of GUI components
        contentPane.setLayout(null);
 
        // set up inputDetailJPanel
        inputDetailJPanel = new JPanel();
        inputDetailJPanel.setBounds(31, 31, 215, 323); // 3rd number controlds length , 4th width 
        inputDetailJPanel.setBorder(new TitledBorder("Account"));
        inputDetailJPanel.setLayout(null);
        contentPane.add(inputDetailJPanel);
 
        // set up custIDJLabel
        custidJLabel = new JLabel();
        custidJLabel.setBounds(8, 32, 90, 23);
        custidJLabel.setText("customer ID");
        inputDetailJPanel.add(custidJLabel);
 
        // set up cusidJTextField
        custidJTextField = new JTextField();
        custidJTextField.setBounds(104, 32, 88, 21);
        custidJTextField.setHorizontalAlignment(JTextField.RIGHT);
        inputDetailJPanel.add(custidJTextField);
 
 
 
        // set up AccountnumJLabel
        acctNumberJLabel = new JLabel();
        acctNumberJLabel.setBounds(8, 56, 100, 23);
        acctNumberJLabel.setText("Account Number:");
        inputDetailJPanel.add(acctNumberJLabel);
 
        // set up AccountnumTextField
        acctNumberJTextField = new JTextField();
        acctNumberJTextField.setBounds(112, 56, 80, 21);
        acctNumberJTextField.setHorizontalAlignment(JTextField.RIGHT);
        inputDetailJPanel.add(acctNumberJTextField);
 
        // set up BalanceJLabel
        balanceJLabel = new JLabel();
        balanceJLabel.setBounds(8, 80, 60, 23);
        balanceJLabel.setText("Balance:");
        inputDetailJPanel.add(balanceJLabel);
 
        // set up BalanceTextField
        balanceJTextField = new JTextField();
        balanceJTextField.setBounds(112, 80, 80, 21);
        balanceJTextField.setHorizontalAlignment(JTextField.RIGHT);
        inputDetailJPanel.add(balanceJTextField);
 
        // set up DateJLabel
        acctDateOpenedJLabel = new JLabel();
        acctDateOpenedJLabel.setBounds(8, 100, 80, 24);
        acctDateOpenedJLabel.setText("Date:");
        inputDetailJPanel.add(acctDateOpenedJLabel);
 
        // set up dateTextField
        acctDateOpenedJTextField = new JTextField();
        acctDateOpenedJTextField.setBounds(114, 105, 80, 21);
        acctDateOpenedJTextField.setHorizontalAlignment(JTextField.RIGHT);
        inputDetailJPanel.add(acctDateOpenedJTextField);
 
 
        // set up CreateAccountButton
        CreateAccountJButton = new JButton();
        CreateAccountJButton.setBounds(112, 152, 80, 26);
        CreateAccountJButton.setText("Create");
        inputDetailJPanel.add(CreateAccountJButton);
        CreateAccountJButton.addActionListener(
 
        new ActionListener() {
            // event handler called when CreateAccountJButton
            // is clicked
            public void actionPerformed(ActionEvent event) {
                CreateAccountJButtonActionPerformed(event);
            }
 
        }
 
        ); // end call to addActionListener
 
         // set up interesrAccountButton
        interestJButton = new JButton();
        interestJButton.setBounds(32, 238, 160, 28);
        interestJButton.setText("intrest");
        inputDetailJPanel.add(interestJButton);
        interestJButton.addActionListener(
 
        new ActionListener() {
            // event handler called when interestAccountJButton
            // is clicked
            public void actionPerformed(ActionEvent event) {
                interestJButtonActionPerformed(event);
            }
 
        }
 
        ); // end call to addActionListener
 
        // set up DeleteAccountButton
        DeleteAccountJButton = new JButton();
        DeleteAccountJButton.setBounds(16, 152, 80, 24);
        DeleteAccountJButton.setText("Delete");
        inputDetailJPanel.add(DeleteAccountJButton);
        DeleteAccountJButton.addActionListener(
 
        new ActionListener() // anonymous inner class
                {
                    // event handler called when DeleteAccountJButton
                    // is clicked
                    public void actionPerformed(ActionEvent event) {
                    DeleteAccountJButtonActionPerformed(event);
 
                    }
 
                }
 
                ); // end call to addActionListener
 
 
 
 
 
         // set up updateJButton
        updateJButton = new JButton();
        updateJButton.setBounds(16, 180, 176, 24);
        updateJButton.setText("update Account ");
        inputDetailJPanel.add(updateJButton);
        updateJButton.addActionListener(
 
        new ActionListener() // anonymous inner class
                {
                    // event handler called when TransactionJButton
                    // is clicked
                    public void actionPerformed(ActionEvent event) {
                        updateJButtonActionPerformed(event);
                    }
 
                } // end anonymous inner class
 
                );
 
        // clear Button          
        clearJButton = new JButton();
        clearJButton.setBounds(18, 210, 176, 24);
        clearJButton.setText("clear");
        inputDetailJPanel.add(clearJButton);
        clearJButton.addActionListener(
 
        new ActionListener() // anonymous inner class
                {
                    // event handler called when clearJButton
                    // is clicked
                    public void actionPerformed(ActionEvent event) {
                        clearJButtonListenerActionPerformed(event);
                    }
 
                } // end anonymous inner class
 
                );
 
 
 
 
        // set up displayJLabel
        displayJLabel = new JLabel();
        displayJLabel.setBounds(250, 26, 190, 33);
        displayJLabel.setText("Account Details:");
        contentPane.add(displayJLabel);
 
        // set up displayJTextArea
        displayJTextArea = new JTextArea();
        displayJTextArea.setBounds(260, 68, 422, 205);
        displayJTextArea.setEditable(false);
        contentPane.add(displayJTextArea);
 
        // set properties of application's window
        setTitle("Bank Accounts"); // set title bar string
        setSize(750, 450); // set window size
        setVisible(true); // display window
 
 
        // set up CreateAccountButton
        displayAccountJButton = new JButton();
        displayAccountJButton.setBounds(42, 238, 140, 58);
        displayAccountJButton.setText("Search");
        inputDetailJPanel.add(displayAccountJButton);
        displayAccountJButton.addActionListener(
 
        new ActionListener() {
            // event handler called when CreateAccountJButton
            // is clicked
            public void actionPerformed(ActionEvent event) {
                displayAccountJButtonActionPerformed(event);
            }
 
        }
 
        ); // end call to addActionListener
 
    } // end method createUserInterface
 
 
 
    private void CreateAccountJButtonActionPerformed(ActionEvent event) {
 
 
              //increment number in array 
 
               i ++ ;
 
              Account [] newaccount = new Account [i] ;
              System.arraycopy(account, 0, newaccount, 0, account.length);
              account=newaccount;
 
 
               balance = Double.parseDouble(balanceJTextField.getText());
               custid = custidJTextField.getText();
               custid = custid.trim();
               acctDateOpened = acctDateOpenedJTextField.getText();
               acctDateOpened = acctDateOpened.trim(); 
               acctNumber = acctNumberJTextField.getText();
               acctNumber = acctNumber.trim();
 
 
              // Check to see if each account array is populated and
             // if not add account details
            if (balance == 0 )
             {
               JOptionPane.showMessageDialog (null, "you initial balance cannot be zero ");
               valid1 = false ;
                         }
              else valid1 = true ;
 
 
 
                  if (balance < 0 )
                        {
                          valid2 = false;
                        JOptionPane.showMessageDialog (null, "Please enter a number for account balance!");
                         }
                      else valid2 = true;
 
 
                    DateTest test = new DateTest();
                   if (acctDateOpened.length() == 0 || test.isValidDate(acctDateOpened)== false)
                        {
                            JOptionPane.showMessageDialog (null, "Enter Account date in correct dd/mm/yyyy format");
                           valid3 = false;
                               }
                             else
                             valid3 = true;
 
                             if (custid.length() != 7)
                                {
                            JOptionPane.showMessageDialog (null, "Please enter apositive 7 digit id number");
                       valid4 = false;
                             }
                         else
                     valid4 = true;
 
                        //validate customer id number
 
                        for (int i = 0; i < custid.length(); i++)
                            {
                              if (!Character.isDigit(custid.charAt(i)))
                                {
                           valid5 = false;
                           JOptionPane.showMessageDialog (null, "Please enter a positive 7 digit id number");
                                }
                       else valid5 = true;
                          }
 
 
                    if (acctNumber.length() == 0)
                      {
                    JOptionPane.showMessageDialog (null, "Please enter an account number");
                    valid6 = false;
                         }
                            else
                                valid6 = true;
 
                           // validate account number is a number
for (int i = 0; i < acctNumber.length(); i++)
{
if (!Character.isDigit(acctNumber.charAt(i)))
{
valid7 = false;
JOptionPane.showMessageDialog (null, "Please enter a number for account number");
}
else valid7 = true;
 
}
 
 
 
 
 
if (valid1 == true && valid2 == true && valid3== true && valid4 ==true && valid5 == true && valid6 == true && valid7 == true )
{
 
 
try {
 
 
 
FileWriter fw = new FileWriter (file, true);
BufferedWriter bw = new BufferedWriter (fw);
PrintWriter outFile = new PrintWriter (bw);
account[i-1] = new Account ( acctNumber , balance , acctDateOpened , custid ) ;
outFile.println ("account number " + account[i-1].getacctNumber() );
outFile.println ("balance " + account[i-1].getBalance () );
outFile.println ("date opened " + account[i-1].getacctDate () );
outFile.println ("customer ID " + account[i-1].getcustid () );
outFile.println();
outFile.close();
JOptionPane.showMessageDialog (null, "Account has been saved at: " + file);
 
 
 
 
 
}
 
catch (Exception e) {
 
JOptionPane.showMessageDialog(null, "Error: File not found");
}
 
//Account acc =account[i-1];
displayJTextArea.setText( "Account Number customerID Date Of Opening balance" + " \n " + account[i-1] + " " + account[i-1].getacctNumber() + " " + account[i-1].getBalance () + " " + account[i-1].getacctDate () + " " + account[i-1].getcustid () );
 
 
 
}
 
}
 
     private void clearJButtonListenerActionPerformed(ActionEvent  event)
        {
 
 
 
                custidJTextField.setText("  ");
 
                acctDateOpenedJTextField.setText(" ");
 
                acctNumberJTextField.setText(" ");
 
                balanceJTextField.setText(" ");
 
        }
 
         private void interestJButtonActionPerformed(ActionEvent  event)
        {
 
 
 
            double  add  =  Double.parseDouble ( JOptionPane.showInputDialog ("enter percentage interest") ) ;
            for (int i = 0; i < account.length; i++) 
                { 
 
               double  B = account[i - 1].getBalance();
 
               double amount  = (add/100) * B; 
               balance  += amount ;
 
              }
 
 
            }
 
 
                  private void displayAccountJButtonActionPerformed(ActionEvent  event)
        {
 
 
 
            String searchAccount =  JOptionPane.showInputDialog (null, "Please enter the account number to search");
            for (int d = 0; i < account.length; d++) 
                { 
 
                    if ( searchAccount.equals(account[i-1].getacctNumber() ) ) 
                      {    displayJTextArea.setText( account[i-1].getacctNumber() ) ; 
                           displayJTextArea.setText( account[i-1].getcustid() ) ;
                           displayJTextArea.setText( " " + account[i-1].getBalance () ) ; 
                           displayJTextArea.setText( account[i-1].getacctDate () ) ; 
 
                        }
                        else {
                          d++;
                        }
 
                        if (d ==account.length)
                    JOptionPane.showMessageDialog(null, "ACCOUNT NOT FOUND");
 
 
 
              }
 
 
            }
 
 
 
    private void DeleteAccountJButtonActionPerformed(ActionEvent event) {
 
 
        String D =  JOptionPane.showInputDialog (null, "Please enter the account number to delete the account");
 
        for ( int c = 0 ; c < account.length; c++ ) 
        {  
            if(  D.equals( account[i].getacctNumber()) )
              { 
                  JOptionPane.showMessageDialog (null , "FOUND");
                  account[i] = null ; 
                } else 
                   { JOptionPane.showMessageDialog (null, "NOT FOUND ");
                    } 
 
            }  
 
 
 
 
        } 
 
 
 
 
 
 
 
    private void updateJButtonActionPerformed(ActionEvent event) {  
 
 
 
 
 
    }
 
 
 
    public static void main(String[] args) {
        // Populate arrays with the word EMPTY
        // so we can check to see if the values are empty later
 
 
 
        BankAccount application = new BankAccount();
        application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
 
}

Edited 6 Years Ago by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

Dude please wrap your code in the

format so it is easier to read first of all and from just scanning through it. It seems you are missing the buttons call to your buttonlistener.

E.g

Create button
Create Listener
Call listener when button is clicked button.Listner()

Thanks for helping i really need and appreciate it

ACCOUNTS CLASS

public class Account {
  // Instance variable 
  private double balance;
  
  String acctNumber ; 

   String dateOpened;
   String custID ; 
   int amountInArray;

  // Constructor 1 (for initial deposit accounts)
  public Account(String acctNum , double bal , String date , String custid) {
           acctNumber = acctNum;
           balance = bal ; 
           date = dateOpened ; 
           custID = custid ; 
  }


 //get the account number
 public String getacctNumber() {
    return acctNumber;
  }
  
  
   //get the account number
 public String getcustid() {
    return custID;
  }

  //get account balance
  public double getBalance() {
    return balance;
  }
  
    public String getacctDate() {
    return dateOpened;
  }
   //close account

}

DATE TEST CLASS , THIS IS ONLY USED TO VERIFY THE DATE ENTERED IS IN CORRECT FORMAT NO NEED TO LOOK THREW THIS JUST COPY AND PASTE IN IN A CLASS SO THE BANK ACCOUNT PROGRAM WORKS

import java.text.SimpleDateFormat;
import java.text.ParseException;

public class DateTest {

  public boolean isValidDate(String inDate) {

    if (inDate == null)
      return false;

    //set the format to use as a constructor argument
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    
    if (inDate.trim().length() != dateFormat.toPattern().length())
      return false;

    dateFormat.setLenient(false);
    
    try {
      //parse the inDate parameter
      dateFormat.parse(inDate.trim());
    }
    catch (ParseException pe) {
      return false;
    }
    return true;
    
 
  }
 
  
}

THIS IS THE BANK ACCOUNT CLASS , i did make the call to the listeners read threw the code and you'll see , now my problem is that none of the buttons are working the way they should. If you can help me to get the interest button working that would be perfect then i would be able to do the rest by myself. I want to be able to create an account , write the account information to a text file and use the interest button to read the information on the file and add a percentage interest to the balance of all the accounts written to the file.

import java.awt.*;
import java.awt.event.*;
import java.text.*;
import javax.swing.*;
import javax.swing.border.*;
import java.util.Arrays;
import java.io.*;
import java.util.Scanner;

public class BankAccount extends JFrame {

    // Make these variables publicly available
    String file = "THUS.txt" ;   
    public static String acctNumber ;
    public static String  custid , acctDateOpened;
    public static double balance ;
  
   
    
    boolean valid1, valid2, valid3, valid4, valid5, valid6, valid7 ;
    
    int i = 0; 
    Account [] account = new Account [i]; 

    
    // JPanel for user inputs
    private JPanel inputDetailJPanel;

    
    // JLabel and Jtext field for custID
    private JTextField acctDateOpenedJTextField;
    private JLabel acctDateOpenedJLabel;
    
    // JLabel and Jtext field for custID
    private JTextField custidJTextField;
    private JLabel custidJLabel;
    
    // JLabel and JTextField for account number
    private JLabel acctNumberJLabel;
    private JTextField acctNumberJTextField;

    // JLabel and JTextField for balance
    private JLabel balanceJLabel;
    private JTextField balanceJTextField;


    // JButton to create account
    private JButton CreateAccountJButton;
    
    //JButton for update
    private JButton updateJButton ; 
    
    //JButton for update
    private JButton interestJButton ; 
    

    //JButton to clear account 
    private JButton clearJButton ; 

    
    
    // JButton to delete account
    private JButton DeleteAccountJButton;

    // initialise display account 
    private JButton displayAccountJButton ; 
    
    
    // JLabel and JTextArea to display account details
    private JLabel displayJLabel;
    private JTextArea displayJTextArea;
    
   



    // constructor
    public BankAccount() {
        createUserInterface();
    }

    // create and position GUI components; register event handlers
    private void createUserInterface() {
        // get content pane for attaching GUI components
        Container contentPane = getContentPane();

        // enable explicit positioning of GUI components
        contentPane.setLayout(null);

        // set up inputDetailJPanel
        inputDetailJPanel = new JPanel();
        inputDetailJPanel.setBounds(31, 31, 215, 323); // 3rd number controlds length , 4th width 
        inputDetailJPanel.setBorder(new TitledBorder("Account"));
        inputDetailJPanel.setLayout(null);
        contentPane.add(inputDetailJPanel);

        // set up custIDJLabel
        custidJLabel = new JLabel();
        custidJLabel.setBounds(8, 32, 90, 23);
        custidJLabel.setText("customer ID");
        inputDetailJPanel.add(custidJLabel);

        // set up cusidJTextField
        custidJTextField = new JTextField();
        custidJTextField.setBounds(104, 32, 88, 21);
        custidJTextField.setHorizontalAlignment(JTextField.RIGHT);
        inputDetailJPanel.add(custidJTextField);
        
        
        
        // set up AccountnumJLabel
        acctNumberJLabel = new JLabel();
        acctNumberJLabel.setBounds(8, 56, 100, 23);
        acctNumberJLabel.setText("Account Number:");
        inputDetailJPanel.add(acctNumberJLabel);

        // set up AccountnumTextField
        acctNumberJTextField = new JTextField();
        acctNumberJTextField.setBounds(112, 56, 80, 21);
        acctNumberJTextField.setHorizontalAlignment(JTextField.RIGHT);
        inputDetailJPanel.add(acctNumberJTextField);

        // set up BalanceJLabel
        balanceJLabel = new JLabel();
        balanceJLabel.setBounds(8, 80, 60, 23);
        balanceJLabel.setText("Balance:");
        inputDetailJPanel.add(balanceJLabel);

        // set up BalanceTextField
        balanceJTextField = new JTextField();
        balanceJTextField.setBounds(112, 80, 80, 21);
        balanceJTextField.setHorizontalAlignment(JTextField.RIGHT);
        inputDetailJPanel.add(balanceJTextField);
        
        // set up DateJLabel
        acctDateOpenedJLabel = new JLabel();
        acctDateOpenedJLabel.setBounds(8, 100, 80, 24);
        acctDateOpenedJLabel.setText("Date:");
        inputDetailJPanel.add(acctDateOpenedJLabel);

        // set up dateTextField
        acctDateOpenedJTextField = new JTextField();
        acctDateOpenedJTextField.setBounds(114, 105, 80, 21);
        acctDateOpenedJTextField.setHorizontalAlignment(JTextField.RIGHT);
        inputDetailJPanel.add(acctDateOpenedJTextField);


        // set up CreateAccountButton
        CreateAccountJButton = new JButton();
        CreateAccountJButton.setBounds(112, 152, 80, 26);
        CreateAccountJButton.setText("Create");
        inputDetailJPanel.add(CreateAccountJButton);
        CreateAccountJButton.addActionListener(

        new ActionListener() {
            // event handler called when CreateAccountJButton
            // is clicked
            public void actionPerformed(ActionEvent event) {
                CreateAccountJButtonActionPerformed(event);
            }

        }

        ); // end call to addActionListener
        
         // set up interesrAccountButton
        interestJButton = new JButton();
        interestJButton.setBounds(32, 238, 160, 28);
        interestJButton.setText("intrest");
        inputDetailJPanel.add(interestJButton);
        interestJButton.addActionListener(

        new ActionListener() {
            // event handler called when interestAccountJButton
            // is clicked
            public void actionPerformed(ActionEvent event) {
                interestJButtonActionPerformed(event);
            }

        }

        ); // end call to addActionListener

        // set up DeleteAccountButton
        DeleteAccountJButton = new JButton();
        DeleteAccountJButton.setBounds(16, 152, 80, 24);
        DeleteAccountJButton.setText("Delete");
        inputDetailJPanel.add(DeleteAccountJButton);
        DeleteAccountJButton.addActionListener(

        new ActionListener() // anonymous inner class
                {
                    // event handler called when DeleteAccountJButton
                    // is clicked
                    public void actionPerformed(ActionEvent event) {
                    DeleteAccountJButtonActionPerformed(event);

                    }

                }

                ); // end call to addActionListener

       
                
                
                
         // set up updateJButton
        updateJButton = new JButton();
        updateJButton.setBounds(16, 180, 176, 24);
        updateJButton.setText("update Account ");
        inputDetailJPanel.add(updateJButton);
        updateJButton.addActionListener(

        new ActionListener() // anonymous inner class
                {
                    // event handler called when TransactionJButton
                    // is clicked
                    public void actionPerformed(ActionEvent event) {
                        updateJButtonActionPerformed(event);
                    }

                } // end anonymous inner class

                );
                
        // clear Button          
        clearJButton = new JButton();
        clearJButton.setBounds(18, 210, 176, 24);
        clearJButton.setText("clear");
        inputDetailJPanel.add(clearJButton);
        clearJButton.addActionListener(

        new ActionListener() // anonymous inner class
                {
                    // event handler called when clearJButton
                    // is clicked
                    public void actionPerformed(ActionEvent event) {
                        clearJButtonListenerActionPerformed(event);
                    }

                } // end anonymous inner class

                );
                
                
                

        // set up displayJLabel
        displayJLabel = new JLabel();
        displayJLabel.setBounds(250, 26, 190, 33);
        displayJLabel.setText("Account Details:");
        contentPane.add(displayJLabel);

        // set up displayJTextArea
        displayJTextArea = new JTextArea();
        displayJTextArea.setBounds(260, 68, 422, 205);
        displayJTextArea.setEditable(false);
        contentPane.add(displayJTextArea);

        // set properties of application's window
        setTitle("Bank Accounts"); // set title bar string
        setSize(750, 450); // set window size
        setVisible(true); // display window
        
        
        // set up CreateAccountButton
        displayAccountJButton = new JButton();
        displayAccountJButton.setBounds(42, 238, 140, 58);
        displayAccountJButton.setText("Search");
        inputDetailJPanel.add(displayAccountJButton);
        displayAccountJButton.addActionListener(

        new ActionListener() {
            // event handler called when CreateAccountJButton
            // is clicked
            public void actionPerformed(ActionEvent event) {
                displayAccountJButtonActionPerformed(event);
            }

        }

        ); // end call to addActionListener

    } // end method createUserInterface
    
    
//////////////////////////////////////////////////////////////////////////////////IMPLEMEMT LISTENERS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


//////////////////////////CREATE ACCOUNT \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    private void CreateAccountJButtonActionPerformed(ActionEvent event) {
                
                
              //increment number in array 
              
               i ++ ;
                     
              Account [] newaccount = new Account [i] ;
              System.arraycopy(account, 0, newaccount, 0, account.length);
              account=newaccount;
              
         
               balance = Double.parseDouble(balanceJTextField.getText());
               custid = custidJTextField.getText();
               custid = custid.trim();
               acctDateOpened = acctDateOpenedJTextField.getText();
               acctDateOpened = acctDateOpened.trim(); 
               acctNumber = acctNumberJTextField.getText();
               acctNumber = acctNumber.trim();
 
 
              // Check to see if each account array is populated and
             // if not add account details
            if (balance == 0 )
             {
               JOptionPane.showMessageDialog (null, "you initial balance cannot be zero ");
               valid1 = false ;
                         }
              else valid1 = true ;
 
 
 
                  if (balance < 0 )
                        {
                          valid2 = false;
                        JOptionPane.showMessageDialog (null, "Please enter a number for account balance!");
                         }
                      else valid2 = true;
 
 
                    DateTest test = new DateTest();
                   if (acctDateOpened.length() == 0 || test.isValidDate(acctDateOpened)== false)
                        {
                            JOptionPane.showMessageDialog (null, "Enter Account date in correct dd/mm/yyyy format");
                           valid3 = false;
                               }
                             else
                             valid3 = true;
 
                             if (custid.length() != 7)
                                {
                            JOptionPane.showMessageDialog (null, "Please enter apositive 7 digit id number");
                       valid4 = false;
                             }
                         else
                     valid4 = true;
 
                        //validate customer id number
 
                        for (int i = 0; i < custid.length(); i++)
                            {
                              if (!Character.isDigit(custid.charAt(i)))
                                {
                           valid5 = false;
                           JOptionPane.showMessageDialog (null, "Please enter a positive 7 digit id number");
                                }
                       else valid5 = true;
                          }
 
 
                    if (acctNumber.length() == 0)
                      {
                    JOptionPane.showMessageDialog (null, "Please enter an account number");
                    valid6 = false;
                         }
                            else
                                valid6 = true;
 
                           // validate account number is a number
                           for (int i = 0; i < acctNumber.length(); i++)
                            {
                              if (!Character.isDigit(acctNumber.charAt(i)))
                                   {
                                     valid7 = false;
                                     JOptionPane.showMessageDialog (null, "Please enter a number for account number");
                                      }
                                   else valid7 = true;
 
                                      }
 
 
 
 
 
                            if (valid1 == true && valid2 == true && valid3== true && valid4 ==true && valid5 == true && valid6 == true && valid7 == true )
                             {
 
 
                  try {
 
 
 
           FileWriter fw = new FileWriter (file, true);
           BufferedWriter bw = new BufferedWriter (fw);
           PrintWriter outFile = new PrintWriter (bw);
           account[i-1] = new Account ( acctNumber , balance , acctDateOpened , custid ) ;
           outFile.println ("account number " + account[i-1].getacctNumber() );
           outFile.println ("balance " + account[i-1].getBalance () );
           outFile.println ("date opened " + account[i-1].getacctDate () );
           outFile.println ("customer ID " + account[i-1].getcustid () );
           outFile.println();
           outFile.close();
           JOptionPane.showMessageDialog (null, "Account has been saved at: " + file);
 
 
 
 
 
                               }
 
                               catch (Exception e) {
 
                               JOptionPane.showMessageDialog(null, "Error: File not found");
                                 }
 
                           //Account acc = account[i-1];
                            displayJTextArea.setText( "account "  + account[1-1].getacctNumber() + " created" );
 
 
 
                              }
 
                     }
                     

///////////////////////////////////////////CLEAR\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    
     private void clearJButtonListenerActionPerformed(ActionEvent  event)
        {
           
                
               
                custidJTextField.setText("  ");
             
                acctDateOpenedJTextField.setText(" ");
           
                acctNumberJTextField.setText(" ");
            
                balanceJTextField.setText(" ");
            
        }
        
/////////////////////////////////////INTEREST\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

  
         private void interestJButtonActionPerformed(ActionEvent  event)
         {
                        
             
            double  add  =  Double.parseDouble ( JOptionPane.showInputDialog ("enter percentage interest") ) ;
            for (int i = 0; i  < account.length; i++) 
                { 
                    Scanner fileScan;
                    try {
               
               fileScan = new Scanner ( file );
               Scanner scan = new Scanner (System.in);
               acctNumber = fileScan.next();
               balance = fileScan.nextDouble() ;
               acctDateOpened = fileScan.next();
               custid = fileScan.next();          
               
            }
            
            
             catch (Exception d) {
             JOptionPane.showMessageDialog (null , "FILE NOT FOUND !!!!!");
                        }
                        
             
               double  B = (double) account[i].getBalance();
               double amount  = (add/100) * B; 
               balance  += amount ;
               
               try {
 
 
 
                          FileWriter fw = new FileWriter (file, false);
                          BufferedWriter bw = new BufferedWriter (fw);
                          PrintWriter outFile = new PrintWriter (bw);
                          account[i] = new Account ( acctNumber , balance , acctDateOpened , custid ) ;
                          outFile.println(); 
                          outFile.println ("account number " + account[i].getacctNumber() );
                          outFile.println ("balance " + account[i].getBalance () );
                          outFile.println ("date opened " + account[i].getacctDate () );
                          outFile.println ("customer ID " + account[i].getcustid () );
                          outFile.println(); 
                          outFile.close();
                          JOptionPane.showMessageDialog (null, "Account has been saved at: " + file);
                          
                          }
 
                             catch (Exception f) {
 
                            JOptionPane.showMessageDialog(null, "Error: File not found");
                          }
 
                        }
               
              }
            
                
            
            
//////////////////////////////////////DISPLAY\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
           
                  private void displayAccountJButtonActionPerformed(ActionEvent  event)
        {
           
               
             
            String searchAccount =  JOptionPane.showInputDialog (null, "Please enter the account number to search");
            for (int i = 0; i < account.length; i++) 
                { 
             
                    if ( searchAccount.equals(account[i].getacctNumber() ) ) 
                      {    displayJTextArea.setText( account[i-1].getacctNumber() + "\n" + account[i-1].getcustid() +  "\n" +  account[i-1].getBalance () + "\n"  + account[i-1].getacctDate ()) ; 
                           
                        }
                        else {
                          i++;
                        }
                        
                        if (i==account.length)
                    JOptionPane.showMessageDialog(null, "ACCOUNT NOT FOUND");
               
         
               
              }
            
                
            }
        
        
////////////////////////////////////////delete\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    private void DeleteAccountJButtonActionPerformed(ActionEvent event) {
        
        
        String D =  JOptionPane.showInputDialog (null, "Please enter the account number to delete the account");
        
        for ( int c = 0 ; c < account.length; c++ ) 
        {  
            if(  D.equals( account[i].getacctNumber()) )
              { 
                  JOptionPane.showMessageDialog (null , "FOUND");
                  account[i] = null ; 
                } else 
                   { JOptionPane.showMessageDialog (null, "NOT FOUND ");
                    } 
                
            }  
               
            


        } 

        
        
      
    
    
////////////////////////////////////////Update\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

    private void updateJButtonActionPerformed(ActionEvent event) {  
        
        
        
        

    }

   

    public static void main(String[] args) {
        // Populate arrays with the word EMPTY
        // so we can check to see if the values are empty later
       
       

        BankAccount application = new BankAccount();
        application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

}

Edited 6 Years Ago by peter_budo: Editing text formatted

sorry about the crappy wording above ,

the date and accounts class work fine , i only need help with the add interest button , i want to be able make and account then write the information to a text file, and later when the interest button is clicked it should read the information from the text file and add a percentage interest to it. if you can help me to get the interest button working properly i should be able to fix the rest by myself

in confused what promgram i will copy, can somebody write this program again? so that i will know what program i will use

in confused what promgram i will copy, can somebody write this program again? so that i will know what program i will use

what program you are going to copy? how about 'none', write your own. about everyone here can re-write this application, but why should we? we don't need it.

what are we supposed to know what (kind of) program you want to use, you didn't even bother to mention what kind of program you're looking for, or what you want to do with it.

if you didn't notice it: this website is for developers to help other developers to imrpove their coding skills, it's not a 24/7 programming services, we are not "developers-for-rent".

1. start your own thread, don't revive one that hasn't been posted in for years
2. explain what you want to achieve
3. show us the code you've written so far, do not expect us to go and do it for you.

This article has been dead for over six months. Start a new discussion instead.