Tamara Robbins
Tamara Robbins

Reputation: 23

Selecting multiple items in two JTables

Does anyone know how I would select a row in one JTable and then it would highlight a row in another JTable?

ListSelectionListener[] listeners = leftJTable.getListeners(ListSelectionListener.class);

Upvotes: 1

Views: 121

Answers (1)

trashgod
trashgod

Reputation: 205855

Yes, two tables can share the same ListSelectionModel:

JTable left = new JTable(...);
JTable right = new JTable(...);
right.setSelectionModel(left.getSelectionModel());

Upvotes: 1

Related Questions