converting selected col index of jtable to its model's col index - Java
This is a discussion on converting selected col index of jtable to its model's col index - Java ; during sorting, the jTable row index no longer match to its model.
hence, i will need to perform the following coversion.
final int row = jTable1.getSelectedRow();
final int modelIndex =
jTable1.getRowSorter().convertRowIndexToModel(row);
however, for the col index, it will also no ...
-
converting selected col index of jtable to its model's col index
during sorting, the jTable row index no longer match to its model.
hence, i will need to perform the following coversion.
final int row = jTable1.getSelectedRow();
final int modelIndex =
jTable1.getRowSorter().convertRowIndexToModel(row);
however, for the col index, it will also no longer match to its model
col index, the user is dragging around the cols. so, how can i
concerted the selected col index to model's?
thank you.
-
Re: converting selected col index of jtable to its model's col index
On Apr 1, 7:31 am, yancheng.ch... wrote:
> during sorting, the jTable row index no longer match to its model.
> hence, i will need to perform the following coversion.
>
> final int row = jTable1.getSelectedRow();
> final int modelIndex =
> jTable1.getRowSorter().convertRowIndexToModel(row);
>
> however, for the col index, it will also no longer match to its model
> col index, the user is dragging around the cols. so, how can i
> concerted the selected col index to model's?
>
> thank you.
Hi Yancheng,
Try something like this, where columnIndex is your selected column
index.
TableColumn column = jTable1.getColumnModel().getColumn(columnIndex);
int modelColumnIndex = column.getModelIndex();
Cheers,
Dan Andrews
-------------------
http://www.ansir.ca
Similar Threads
-
By Application Development in forum CSharp
Replies: 0
Last Post: 12-06-2007, 04:53 AM
-
By Application Development in forum CSharp
Replies: 0
Last Post: 11-09-2007, 12:48 PM
-
By Application Development in forum CSharp
Replies: 2
Last Post: 08-15-2007, 10:39 AM
-
By Application Development in forum Java
Replies: 2
Last Post: 03-22-2007, 02:25 AM
-
By Application Development in forum Javascript
Replies: 2
Last Post: 11-14-2003, 04:29 AM