File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Table model event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Table model event" Watch "Table model event" New topic
Author

Table model event

Eugenio Flores
Ranch Hand

Joined: Sep 13, 2007
Posts: 38
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

Joined: Jun 09, 2003
Posts: 4632
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

 
wood burning stoves
 
subject: Table model event