This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Setting the data in a JTable  RSS feed

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table, that allows users to sort the data. They can also select any of the rows in the JTable, and it throws the information into text fields, so they can modify the data. Once they hit save, the data in the table is refreshed. My problem I am running into, is if the user has sorted the table into the order they want it, then hit save, the data in the JTable is set back to its original order.
How can I refresh the data of the JTable when it changes, without reordering the rows?

Below is how I am setting the data of the table:



And I am using Sun's TableSorter class to sort the columns
Here is a link to that class:
TableSorter

Thanks for any help!!
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I found a workaround. I added a variable to TableSorter that holds the index of the last column sorted on. Whenever I refresh the data in the table, I run the sortByColumn() method on the TableSorter class using the
index of the last column that was sorted on.

If anyone has a better solution, please let me know!

Thanks!
 
Good night. Drive safely. Here's a tiny ad for the road:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!