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
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.
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.
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
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
> 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(...).
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.