Link to home
Start Free TrialLog in
Avatar of spowers
spowers

asked on

jtable

Hi,
I have a table that I am populating from a database.  I have set it up DefaultTableModel(vector, vector)

I would like to be able to allow the user to select multiple rows and then detect the values of the selection.  Ex

01      A      A      A
02      B      B      B
03      C      C      C

if the user has selected 01 and 02 I would like to see the values A   A   A and B  B  B.  Or if the user just selects 03 see the values C  C  C.  Or if the user selects all three rows see all the values.

 I have been playing around with the List Selection Listener, but haven't been able to have much luck.

Thanks
Avatar of expertmb
expertmb

ASKER CERTIFIED SOLUTION
Avatar of vivexp
vivexp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of spowers

ASKER

Hi,
I have this working:  
int index = siteTable.getSelectedRow();
Object test;
test = model.getValueAt(index, 0);

I can't get it working if I have more than one row selected.  I have tried int[] index = siteTable.getSelectedRows();
But I can't detect which values are in the selected rows.  I have tried to stick it in:
for (int i = 0; i< index.length; i++)
                    {
                        sdf = model.getValueAt(i, 0);
                    }
This doesn't work.  Any suggestions?