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
spowersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

expertmbCommented:
0
vivexpCommented:
Hi,


try to use
public int[] getSelectedRows()
     Returns the indices of all selected rows.
Using getValueAt() method of Default table model u can get the
values selected by the user.


Best of luck
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
spowersAuthor Commented:
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?
           
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.