Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Table model event

 
Eugenio Flores
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
I'm using a table component made by SwinLabs (http://swinglabs.org/docs.jsp). The component's name is JXTable.
With that table I'm able to sort the table at runtime, and change the columns' order, using the table's header.

My problem is that when a user orders the table using the column header, the table's model does not change. So If I select a row after the table has been ordered by de user, I won't be able to select the row with the new order because the model does not change, I will get the row with the original model.

So, I'm looking for a table event that I could use to redefine the table's model when the user changes de order at runtime.

Can anyone help me with this issue?

Thanks in advance
Eugenio Flores


 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can't help with JXTable (perhaps they have a forum of their own?), but for a standard JTable,
table.getRowSorter().convertRowIndexToModel(row);
is probably what you'd need.

simple demo, click any of the cells in column 'A', output should all be the same.
click a few of them to check.
click header 'A', to sort.
now click any of the cells in column 'A', to see different output, but 1st and 3rd should be the same

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic