Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem updating JTable

Reply
Thread Tools

Problem updating JTable

 
 
Jorge Castro
Guest
Posts: n/a
 
      07-29-2003
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


 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      07-29-2003
On Tue, 29 Jul 2003 20:16:19 +0100, "Jorge Castro"
<(E-Mail Removed)> wrote or quoted :

>I add a new record to the database.


you do know you must do this on the SWING thread.


--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      07-30-2003
"Jorge Castro" <(E-Mail Removed)> writes:
> Can anyone suggest the cause for this apparent problematic behaviour?


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

/Thomas
 
Reply With Quote
 
Jorge Castro
Guest
Posts: n/a
 
      07-30-2003
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
"Roedy Green" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Tue, 29 Jul 2003 20:16:19 +0100, "Jorge Castro"
> <(E-Mail Removed)> wrote or quoted :
>
> >I add a new record to the database.

>
> you do know you must do this on the SWING thread.
>
>
> --
> Canadian Mind Products, Roedy Green.
> Coaching, problem solving, economical contract programming.
> See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Jtable live updating problem fishinastorm Software 0 06-26-2010 01:15 AM
Updating JTable Atomically - block data changes while updating. news.rcn.com Java 2 12-10-2007 11:49 AM
Putting a JTable inside a JTable cell? Tivo Escobar Java 1 04-12-2007 11:09 AM
How to move data from a CSV file to a JTable, and from a JTable to a CSV file ? Tintin92 Java 1 02-14-2007 06:51 PM
Updating JTable Cells with Custom Renderer Bryan R. Meyer Java 4 09-06-2004 06:01 AM



Advertisments