• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Real-time TableModel Update Suggestions

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Brian,
Nice to see you back
 
Deuphil Kaufmann
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic