• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

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
0
spowers
Asked:
spowers
1 Solution
 
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
 
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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now