This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

TableSorter and Selection gives problems

Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm trying to use a JTable in combination with the Sun TableSorter (v2.0 02/27/04). All works fine, but the user selection on the JTable disappears, when rows are added dynamically.

TableSorter provides a the method public int modelIndex(int viewIndex), so it's always possible to modify the correct row in the tablemodel when you only have an index of the view.
However, what I need is to retreive the index of the view, while I only have the index of the tableModel.

It works like this:
1. Before I add a row to the tableModel, I can get the selected rows from the JTable, and retrieve the indexes of the tableModel with the method modelIndex.
2. Then I add the row. Practically it is inserted in the view, because my Table is sorted. The row is added to the end of the TableModel, but inserted somewhere at an unknown place in the JTable.
3. I still have the tableModel indexes of the selected rows, and I just need to know their view indexes. But here I'm stuck. There's no way I can convert a modelIndex to a viewIndex.

By the way I'm using MULTIPLE_INTERVAL selections.

Here's the Sun TableSorter I'm using:

[ June 23, 2005: Message edited by: Grub de Bliek ]
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you use the getViewToModel method?
What's that smell? Hey, sniff this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!