ArrayIndexOutOfBoundsException gui jlist
<p>Hello i am trying to make a program that will allow me to load in a file and upload the name of it to a list. Once i select a file name in the list it should go through that file and take each line an put it in the specified jtextfield. But when i try and load a second file and try and select it, it tells me arrayIndexOutOfBounds. Can someone please explain to me what I'm doing wrong. I am using NetBeans.</p>

<pre><code>    /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package prog24178.assignment4;

import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;

public class CustomerView extends javax.swing.JFrame {

    /**
     * Creates new form CustomerView
     */
    private Application ass4App = new Application();
    public ArrayList&lt;Customer&gt; customer = new ArrayList&lt;Customer&gt;();
    public ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();
    public String fileName;
    public Customer customers = new Customer();
    public int i;

    public void setApplication(Application customerApp) {
        this.ass4App = ass4App;
    }

    public CustomerView() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */

    private void jExitItemActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        System.exit(0);
    }                                         

    private void jOpenCusItemActionPerformed(java.awt.event.ActionEvent evt) {                                             
        // TODO add your handling code here:
        String currentPath = System.getProperty("user.dir");
        JFileChooser fc = new JFileChooser();

        fc.setMultiSelectionEnabled(true);
        fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
        if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            File[] file = fc.getSelectedFiles();
            for (int i = 0; i &lt; file.length; i++) {
                try {
                    customers.constructCustomer(file[i]);
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(CustomerView.class.getName()).log(Level.SEVERE, null, ex);
                }
                customer.add(customers);
                names.add(customer.get(i).getName());
            }

            jCustomerList.setListData(names.toArray());            
        }
    }                                            

    private void jCustomerListValueChanged(javax.swing.event.ListSelectionEvent evt) {                                           
        // TODO add your handling code here:             
        jCusNameField.setText((String) customer.get(jCustomerList.getSelectedIndex()).getName());
        jAddressField.setText((String) customer.get(jCustomerList.getSelectedIndex()).getAddress());
        jCityField.setText((String) customer.get(jCustomerList.getSelectedIndex()).getCity());
        jProvinceField.setText((String) customer.get(jCustomerList.getSelectedIndex()).getProvince());
        jPostalCodeField.setText((String) customer.get(jCustomerList.getSelectedIndex()).getPostalCode());
        jEmailAddressField.setText((String) customer.get(jCustomerList.getSelectedIndex()).getEmailAddress());
        jPhoneNumberField.setText((String) customer.get(jCustomerList.getSelectedIndex()).getPhoneNumber());

    }             
</code></pre>

<p>I fix the problem. I realized that i was just adding the variable customers to customer without giving it a proper value. 
   customer.add(customers.constructCustomer(file[i]));</p>
