This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes IndexOutOfBounds using JTable which uses List abstractTableModel ListSelectionModel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "IndexOutOfBounds using JTable which uses List abstractTableModel ListSelectionModel" Watch "IndexOutOfBounds using JTable which uses List abstractTableModel ListSelectionModel" New topic
Author

IndexOutOfBounds using JTable which uses List abstractTableModel ListSelectionModel

Shell Durham
Greenhorn

Joined: May 27, 2014
Posts: 2
Please can anyone help with this problem, I keep getting IndexOutOfBounds exceptions in several circumstances, eg:
* add student & then click on the last student displayed in the table
* delete student & then click on the student after the one that was deleted in the table
* delete the last record in the table
* probably more

Part of the stack trace:
==============


NetBeans 8.1 Code: https://www.dropbox.com/sh/rck6j5301avco4s/AACBqAkFYwvgc3HkeDfZZmt_a

Only Student & Lecturer coding is finished so far & found IndexOutOfBound problems when testing.
* Hierarcy for Student Code
view.MvcApp (main app)
view.MainFrame (JFrame with menu bar)
view.StudentView (JPanel,JTable,etc used in JFrame)
controller.StudentController
dao.StudentDAO
util.dbUtility (accesses c:/myjava/A2/SIT751db.accdb)
model.Student

view.StudentView extracts
=========================


controller.StudentController extracts
=====================================



controller.StudentTableModel extracts
=====================================



Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19693
    
  10



I haven't studied your code in detail, but taking this code at face value, you get a row index from one object and then look for that row in a different object.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43389
    
  32
Welcome to the Ranch
I had to put some end of line characters in your stack trace because the long lines are very difficult to read.
Shell Durham
Greenhorn

Joined: May 27, 2014
Posts: 2
Thanks guys.

I managed to fix it, here is the altered code


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: IndexOutOfBounds using JTable which uses List abstractTableModel ListSelectionModel
 
It's not a secret anymore!