| Author |
Selecting a row in one JTable should select the same row in another JTable
|
Ramu Eedupalli
Greenhorn
Joined: Apr 10, 2009
Posts: 9
|
|
Hi,
I have two JTables and i am using one TableModel for two JTables. If I select a row in one JTable then how to automatically select the same row in another JTable? I tried it by overriding valueChanged function in one JTable, if selection changed then i am selecting same row of another JTable in valueChanged function. This is working but If the data in TableModel changed then I am getting exceptions.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Check out what JTable.getSelectionModel() returns, and what methods it has.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8434
|
|
JTable also offers a set selection model as well.
Sharing the same selection model between the tables should fix your problem.
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Ramu Eedupalli
Greenhorn
Joined: Apr 10, 2009
Posts: 9
|
|
|
Thank you. It solved the problem.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Maneesh Godbole wrote:JTable also offers a set selection model as well.
Sharing the same selection model between the tables should fix your problem.
Why do I also miss the easiest solutions?
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8434
|
|
Because it was your turn this time
|
 |
 |
|
|
subject: Selecting a row in one JTable should select the same row in another JTable
|
|
|