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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
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?
visit this
http://www2.gol.com/users/tame/swing/examples/JTableExamples3.html
mb...