getting a object returned from a row selection on a JTable

I've built a jTable and added records to it from an custom object that i've built which all seems to work fine.

Here is the thing i want to show some values in the table not all of them, but when the user selects the row they want i want to get the full object back and display in a series of text, checkboxes and such the rest of the values. now when i have the whole list showing i can use the selection index and match it up to the original collection but when i add a filter the selection index doesn't match the original collection any more.

And if you filter your objects and have a new list of the remaining objects - in order to show the remaining fields - why do you need
to have original index ? First you show some fileds of the object then you show the remianing fields of the same object when the user selects it - don't see
why that would be a problem

0

CloudStrife209Author Commented: 2011-09-21

"First you show some fileds of the object then you show the remianing fields of the same object when the user selects it"

that would be my problem as i'm not doing that right, only way i could figure out how to only show some fields and show the others when the user selected it was to match up the records to the original collection.

manitain ArrayList of your objects and put that ArrayList as the basis of your TableModel

then you filter your ArrayList to a shorter ArrayList but the idea remains the same - tthe new ArrayList will be the basis
of the TableModel

If you could paste some code that would be slef-standing and I could compile it - I couyld try
to understand it in a more concrete way - otherwise it is difficult to understand extensive
blocks of code by sightreading

0

CloudStrife209Author Commented: 2011-09-21

i'm not sure if this is a problem but its not an arraylist it's simply an array of the object

In general ArrayList' s are more convenient than arrays, but in this respect it should not be that different -
just create TableModel around the array of your objects.
When you filter this array to another array - set this new array at the basis of TableModel
(say make the method setArray.. or something)

Your Occupation class is good, but still i cannot compile the whole thing,
but try to do it this way - I see no reason why you cannot do it the way I mentioned