aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Real-time TableModel Update Suggestions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Real-time TableModel Update Suggestions" Watch "Real-time TableModel Update Suggestions" New topic
Author

Real-time TableModel Update Suggestions

Deuphil Kaufmann
Greenhorn

Joined: Feb 22, 2009
Posts: 4
i have an application with which is distributed to many user sharing 1 common db. my concern is, is there any way to make updating jtables/tablemodels better instead of using threads and such,,,my updating is functioning well, but i want to make my jtable/tablemodel always up-to-date with the data without the user noticing any hangs or performance issues... i'm using abstrattablemodel as my basis for my tables, i i call a reload() method in which it re-populates the model's vector and set it again to the jtable, any suggestions? i've searched for some solutions they all point to same things. and also, data from the database is more than 100 records, minimum,,,, i'm pondering in using pagination instead, seems weird, but seems to be the best solution while limiting the data loaded, yet still updated. any directions suggestion are welcome...thanks!
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Deuphil Kaufmann wrote:i have an application with which is distributed to many user sharing 1 common db. my concern is, is there any way to make updating jtables/tablemodels better instead of using threads and such,,,my updating is functioning well, but i want to make my jtable/tablemodel always up-to-date with the data without the user noticing any hangs or performance issues... i'm using abstrattablemodel as my basis for my tables, i i call a reload() method in which it re-populates the model's vector and set it again to the jtable, any suggestions? i've searched for some solutions they all point to same things. and also, data from the database is more than 100 records, minimum,,,, i'm pondering in using pagination instead, seems weird, but seems to be the best solution while limiting the data loaded, yet still updated. any directions suggestion are welcome...thanks!


Well you're probably going to have to use "threads and such," but you're doing something wrong if there are hangs or performance issues.

So your reload() method reloads every row and then calls JTable.setModel()?? I would recommend instead keeping the same model throughout, but push new values into it when appropriate and call AbstractTableModel's fireTableCellUpdated() or fireTableRowsUpdated() so the table can update itself.

Also you might want to use a more efficient Collection class than java.util.Vector.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9995
    
    7

Brian,
Nice to see you back


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Deuphil Kaufmann
Greenhorn

Joined: Feb 22, 2009
Posts: 4
Brian Cole wrote:
Deuphil Kaufmann wrote:i have an application with which is distributed to many user sharing 1 common db. my concern is, is there any way to make updating jtables/tablemodels better instead of using threads and such,,,my updating is functioning well, but i want to make my jtable/tablemodel always up-to-date with the data without the user noticing any hangs or performance issues... i'm using abstrattablemodel as my basis for my tables, i i call a reload() method in which it re-populates the model's vector and set it again to the jtable, any suggestions? i've searched for some solutions they all point to same things. and also, data from the database is more than 100 records, minimum,,,, i'm pondering in using pagination instead, seems weird, but seems to be the best solution while limiting the data loaded, yet still updated. any directions suggestion are welcome...thanks!


Well you're probably going to have to use "threads and such," but you're doing something wrong if there are hangs or performance issues.

So your reload() method reloads every row and then calls JTable.setModel()?? I would recommend instead keeping the same model throughout, but push new values into it when appropriate and call AbstractTableModel's fireTableCellUpdated() or fireTableRowsUpdated() so the table can update itself.

Also you might want to use a more efficient Collection class than java.util.Vector.


i actually use only one tablemodel, and use reload() to populate the it with new data, the problem is, once it tries to gather new data, you can notice the scrolling lagging, i guess it is something with repainting the content of the jtable thats causing it, so i would an alternative to that...thanks for the reply by the way, i'll try with collections instead...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Real-time TableModel Update Suggestions
 
Similar Threads
jtable not updating properly...
Centering in JTable
JTable
Extending JTable
Wanted: conceptual tutorial on JTable