The abstractTableModel seems to want me to have a multidimensional array as the object that holds the data for my JTable. Specifically, the methods getValueAt(int row, int col) and setValueAt(int row, int col) force me to think in terms of an array. what if I have an ArrayList full of "Fish" objects? first solution is to map column numbers to the names of the fields in my object, but that is insane. second solution is that I can make each column of a certain type (example: Species,weight,length,FishID,stomachContents) and use the column type to look up the value of the field for the object at this row. what is the best practice for this?
The names of your columns should be descriptive of what it is your table models. The 2d array is an object which is just used to hold the dataset for your table. HTH Nigel [ April 15, 2004: Message edited by: Nigel Browne ] [ April 15, 2004: Message edited by: Nigel Browne ]
Thanks Nigel, So, you are saying that I could write out the contents of each "Fish" object to an array and use that array to communicate with the table. and I can keep an ArrayList of "Fish" arrays which I can then access with the (x,y) coordinates that the position on the table returns. I will try this out As long as I keep the column names coordinated with the order of fields from the object, I should be OK. If I decide I need to change the order of column names, I would need to go back to my Fish array and change the order of fields in that array.