So, I don't even know where to start with tracking down the cause of this one... I've tried reading the exception (it actually throws two exceptions!), but only one line even references anything in my code (during part of the second exception). I'll post the actual exceptions thrown last, as they are quite long.

Anyways, I have a `JTable` in which each row displays some of the fields of a `Part` object. Three of these fields are of type `Boolean`, and are displayed as check boxes. I have a method which listens for cell selections and whenever a cell is selected, it gets the row selected, (needed since each row corressponds to a `Part` object in an `ArrayList<Part>` (it doesn't do anything with this information yet). The method has been confirmed to behave as expected when any of the non-`Boolean` cells are selected.

***I have isolated the problem to the actual clicking of the checkbox(changing state). The exceptions are thrown when the `Boolean` type cells are toggled, not on any other type of cell. In addition, the problem does not happen when the body of the `valueChanged()` method is commented out.***

**If you need any additional information, I am happy to provide it. I would really appreciate the help; I don't even know where to start here.**

```
public class SelectionListener implements ListSelectionListener
{
    JTable table;
    Integer row;
    Part selectedPart;

    SelectionListener(JTable table)
    {
        this.table = table;
    }

    @Override
    public void valueChanged(ListSelectionEvent e)
    {
        row = e.getFirstIndex();
        selectedPart = Data.parts.get(row);
    }
}

```

### Giant wall of Exception below!

```
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 6, Size: 5
    at java.util.ArrayList.rangeCheck(ArrayList.java:635)
    at java.util.ArrayList.get(ArrayList.java:411)
    at stockcheck.SelectionListener.valueChanged(SelectionListener.java:27)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:184)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:164)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:211)
    at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:405)
    at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:415)
    at javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:459)
    at javax.swing.JTable.changeSelectionModel(JTable.java:2389)
    at javax.swing.JTable.changeSelection(JTable.java:2456)
    at javax.swing.plaf.basic.BasicTableUI$Handler.adjustSelection(BasicTableUI.java:1115)
    at javax.swing.plaf.basic.BasicTableUI$Handler.mousePressed(BasicTableUI.java:1038)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:280)
    at java.awt.Component.processMouseEvent(Component.java:6502)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4489)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 6, Size: 5
    at java.util.ArrayList.rangeCheck(ArrayList.java:635)
    at java.util.ArrayList.get(ArrayList.java:411)
    at stockcheck.SelectionListener.valueChanged(SelectionListener.java:27)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:184)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:154)
    at javax.swing.DefaultListSelectionModel.setValueIsAdjusting(DefaultListSelectionModel.java:685)
    at javax.swing.plaf.basic.BasicTableUI$Handler.setValueIsAdjusting(BasicTableUI.java:954)
    at javax.swing.plaf.basic.BasicTableUI$Handler.mouseReleased(BasicTableUI.java:1166)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

```

EDIT: Additional classes added.
===============================

Other classes posted below:
---------------------------

Data class:

```
public class Data implements Serializable
{    
    private static final long serialVersionUID = 1L;
    // Fields that will be saved:
    protected static ArrayList<Part> parts;
    // Fields that won't be saved:
    private transient ObjectOutputStream outputStream;
    private transient ObjectInputStream inputStream;
    private transient FileOutputStream fileOut;
    private transient FileInputStream fileIn;
    private transient File saveFileObject;
    private transient Integer retryCount = 0;

    protected Data()
    {  
        parts = new ArrayList<>();
        loadData();    // I DEALT WITH THAT BITCH
    }

    protected void saveData()
    {
        // Attempt to serialize...
        try
        {
            // Second param is false; this causes overwrite of existing file.
            fileOut = new FileOutputStream(saveFileObject, false);  
            outputStream = new ObjectOutputStream(fileOut);
            outputStream.writeObject(parts);
            outputStream.flush();
            outputStream.close();
        }
        catch(FileNotFoundException e)
        {
            saveFileObject = new File("savedata.ser");
            if(retryCount < 1)
            {
                retryCount++;
                saveData(); // Recursive retry
            }   
        }
        catch(IOException e)
        {
            System.out.println("Caught IOException when saving!"
                    + " " + "Attempting to recover!");
            retryCount++;
            if (retryCount < 1)
            {
                saveData(); // Recursive retry
            }
        }
    }

    @SuppressWarnings("unchecked")
    private void loadData()
    {   
        // CLEAN UP TRY CATCH BLOCKS; USE MULTICATCH!!!
        // Gets/creates file object.
        saveFileObject = new File("savedata.ser");

        if(!saveFileObject.exists())
        {
            try
            {
                saveFileObject.createNewFile();
            }
            catch(IOException e)
            {
                System.out.println("Uh oh...");
                System.out.println("");
                System.out.println("What? You want an explanation?");
                System.out.println("Fine... IOException caught when creating"
                        + " new save file!");
            }
        }
        // Create file input stream
        try
        {
            fileIn = new FileInputStream(saveFileObject);
        }
        catch (FileNotFoundException e)
        {
            System.out.println("Caught FileNotFoundException!");
        }
        // Create object input stream
        try
        {
            inputStream = new ObjectInputStream(fileIn);
        }
        catch(IOException e)
        {
            System.out.println("Caught IOException when creating object"
                    + " input stream! Attempting to recover by returning!");
            return;
        }
        // Try to deserialize
        try
        {
            parts = (ArrayList<Part>)inputStream.readObject();
        }
        catch(EOFException e)
        {
            System.out.println("EOFException caught! Attempting to recover!");
            return;
        }
        catch(ClassNotFoundException e)
        {
            System.out.println("ClassNotFoundException caught");
        }
        catch(IOException e)
        {
            System.out.println("IOException caught when deserializing!");
            return;
        }
        // close input stream
        try
        {
            inputStream.close();
        }
        catch(IOException e)
        {
            System.out.println("IOException caught when closing input stream!");
            return;
        }
    }
    // Accessor Methods;
    protected static ArrayList<Part> getParts()
    {
        return parts;
    }
    protected Part getPart(int index)
    {
        return parts.get(index - 1);
    }
}

```

Table Model:

```
public class MyTableModel extends RowTableModel<Part>
{
    // Declarations:
    private static String [] COLUMN_NAMES =
    {
       "Name",
       "Make",
       "Part #",
       "Alt. part #",
       "Price",
       "Qty.",
       "Auto?",
       "Marine?",
       "Indust?"
    };
    private int iterator;

    public MyTableModel()
    {
        super(Arrays.asList(COLUMN_NAMES));
        // Set the class of data used by the rows...
        setRowClass(Part.class);
        // Assigning a class type to each column...
        setColumnClass(0, String.class);
        setColumnClass(1, String.class);
        setColumnClass(2, String.class);
        setColumnClass(3, String.class);
        setColumnClass(4, Double.class);
        setColumnClass(5, Integer.class);         
        setColumnClass(6, Boolean.class);
        setColumnClass(7, Boolean.class);
        setColumnClass(8, Boolean.class);
        // Add parts from parts ArrayList to table rows...
        initialAddParts();
    }

    @Override
    public Object getValueAt(int row, int column)
    {
        Part part = getRow(row);         // Gets the part in question

        switch(column)
        {
            case 0:
                return part.getPartName(part);
            case 1:
                return part.getMake(part);
            case 2:
                return part.getPartNumber(part);
            case 3:
                return part.getAltPartNumber(part);
            case 4:
                return part.getPrice(part);
            case 5:
                return part.getQuantity(part);
            case 6:
                return part.isAutomotive(part);
            case 7:
                return part.isMarine(part);
            case 8:
                return part.isIndustrial(part);

            default:
                return null;     // This shouldn't ever be called.
        }
    }

    @Override
    public void setValueAt(Object newValue, int row, int column)
    {
        Part part = getRow(row);    // Get's the part to modify

        switch(column)
        {
            // Standard cases:
            case 0:
                part.setName((String) newValue);
                break;
            case 1:
                part.setMake((String) newValue);
                break;
            case 2:
                part.setPartNumber((String) newValue);
                break;
            case 3:
                part.setAltPartNumber((String) newValue);
                break;
            case 4:
                part.setPrice((Double) newValue);
                break;
            case 5:
                part.setQuantity((Integer) newValue);
                break;
            // Flagging cases:
            case 6:
                part.toggleAutomotive();
                break;
            case 7:
                part.toggleMarine();
                break;
            case 8:
                part.toggleIndustrial();
                break;
            // Default: (Should never be reached)
            default:
                System.out.println("Wait, what?");
                return;
        }
        // Now we can notify the table we messed with it's data
        fireTableCellUpdated(row, column);
    }

    // Initialization Methods:

    private void initialAddParts()
    {
        iterator = 0;
        try
        {
            while (iterator < Data.getParts().size())
            {
                addRow(Data.getParts().get(iterator));
                iterator++;
            }
        }
        catch(NullPointerException e)
        {
            System.out.println("Caught NullPointerException during "
                    + "initialAddParts. Attemting to recover by"
                    + " returning...");
            return;
        }
    }

}

```