JTable, fireTableDataChanged, selection

N

Nosnos

I use fireTableDataChanged to notify my Jtable to update, but when my JTable
updated, the previous selected rows (could be multiple) are lost ...

I want to know how to do to keep these selections when refreshing JTable by
this way ?

thx a lot
 
B

Babu Kalakrishnan

Nosnos said:
I use fireTableDataChanged to notify my Jtable to update, but when my JTable
updated, the previous selected rows (could be multiple) are lost ...

I want to know how to do to keep these selections when refreshing JTable by
this way ?

The fireDataChanged event implies that the data in all the rows of a
JTable could have changed, and rows could have got deleted/added, so it
seems a very reasonable thing to forget the selection status. Otherwise
you could get into situations where the selectionModel is trying to keep
a non-existent row selected.

In case you want to implement this, you need to first remember the
selectionStatus, mutate the data in the table, fire the events and
reselect the rows programmatically if they are still relevant.

BK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,043
Members
48,769
Latest member
Clifft

Latest Threads

Top