JTable JMS and update issue

I have JMS sending messages to my JTable. so onMessage my client listen for messages and updates the table accordinly,

but my JTable flickers a lot if i use fireTableDataChanged() and looks wierd.

I am using defaultTableModel (extended class).

Please any can guide me how to update JTable Dynamically whenever i get messages on method onMessage(..)

Thanks

[386 byte] By [amit_shah25a] at [2007-10-2 21:51:33]
# 1
fireTableDataChanged() cause the TableColumnModel and TableHeaders to be recreated all the time. A better approach would be to use the add, insert and remove methods of the DefaultTableModel then only the rows affected will be repainted.
camickra at 2007-7-14 1:07:25 > top of Java-index,Desktop,Core GUI APIs...
# 2
There should also be an article somewhere about writing this sort of regularly-updating component. It was for a "christmas tree" (ie, lots of flashing lights) component so I think a search for "christmas tree jtable" might find it.Hope this helps.
KPSeala at 2007-7-14 1:07:25 > top of Java-index,Desktop,Core GUI APIs...
# 3

i have my own tableModel which extends DefaultTableModel and i have getValueAt(..) and setValueAt(..) overriden. i am just updating rows values, not adding new or deleting.

is there any other method apart from fireTableDataChanged(..) that i can use,

I tried using firetableRowsUpdated(..) but that does not work either.

Thanks

amit_shah25a at 2007-7-14 1:07:25 > top of Java-index,Desktop,Core GUI APIs...
# 4
"Doesn't work" in what way? Does it still flicker or does it not update the displayed values?What sort of message rate are you getting through your table?
KPSeala at 2007-7-14 1:07:25 > top of Java-index,Desktop,Core GUI APIs...
# 5
if i dont use the fireTableDataChanged(..) then it does not flicker, but values are not getting updated. if i minimize and maximize ( try to repaint) i see changed values.i get like 10-20 messages per second to update rows of table.is there any other work around that i can
amit_shah25a at 2007-7-14 1:07:25 > top of Java-index,Desktop,Core GUI APIs...
# 6

> i have getValueAt(..) and setValueAt(..) overriden

I see no need to override those methods. The setValueAt(..) method in particular will fire the appropriate event to make sure the cell gets repainted.

Here is a simple example that shows how to update the data:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=597870

Maybe the key is that you need to use the SwingUtilities.invokeLater(...).

camickra at 2007-7-14 1:07:25 > top of Java-index,Desktop,Core GUI APIs...
# 7
thanks for that tip it worked now. but now i can select the rows on table because of constant update. my selection is gone.can any one tell me how to fix it?Thanks
amit_shah25a at 2007-7-14 1:07:26 > top of Java-index,Desktop,Core GUI APIs...
# 8
Updating the TableModel does not affect the selection. Just remove the changeSelection() method from my sample code and your original selection will remain.
camickra at 2007-7-14 1:07:26 > top of Java-index,Desktop,Core GUI APIs...
# 9

i was able to fix the selection issue also, but one strange thing i noticed is

after certain time i get outofMemory exception.

do you know reason what i may be doing wrong.

all i do is

SwingUtilities.invokeLater(new Runnable() {

public void run() {

getJTable().setValueAt(new Double(5.00),2,1);

}

});

to update the table and thats about it. then why am i getting outofmemoryException.

thanks again for your help.

amit_shah25a at 2007-7-14 1:07:26 > top of Java-index,Desktop,Core GUI APIs...