Problem updating JTable

J

Jorge Castro

Hi,

I am having the following annoying problem with a JTable(MyTableModel).
After constructing a MyTableModel extends AbstractTableModel, which gets its
data from a remote (RMI) database,
I add a new record to the database.

At this point, upon reception of a notification event from the remote
database triggered by the
successfull addition of the new record, another object triggers execution of
the fireTableRowsUpdated() method of the MyTableModel .

The fireTableRowsUpdated() sends an event to its listeners, in this case the
JTable, causing it to read the new data from
the remote database, updating itself.

This is the theory. What is happenning in practice is that:

1) the fireTableRowsUpdated() is called correctly

2) although I cannot verify that the JTable has received the above event, it
appers to have done so because
, in addition to being in the list of listeners of MyTableModel, I can
verify that some of the methods of the
AbstractTableModel get called (as they should) to updata the JTable.
For example after the new record is added to the database, the getRowCount()
and the getValueAt() are both called,
and try to read data from the database.

However, it appears that the getValueAt() method is not called enough times
to fully update the JTable and the new record
is not shown at all. Only when I mouse click on one of the cells are all
records displayed including the new added recorded.

Can anyone suggest the cause for this apparent problematic behaviour?
Why does the JTable fail to redraw itself showing the new record, after the
fireTableRowsUpdated() is called?

Thanks a lot

Jorge Castro
 
T

Thomas Weidenfeller

Jorge Castro said:
Can anyone suggest the cause for this apparent problematic behaviour?

A very fare fetched guess would be to check your threading behavior.

/Thomas
 
J

Jorge Castro

Thanks for replying.

I have a good feeling about your sugestion.


My client GUI only uses one (main) thread (for the time being), so how do I
fire the table change event on the Swing thread?

Thanks





Jorge Castro
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top