strange behavior of JTable..Help plz
Hi,
Assume i have 5 rows in my JTable. I wrote a function on right click i get a popup window with an option delete row, which deletes the row successfully,
The problem is when i sort the data in JTable. on column click JTable is getting sorted, in which assume 2nd row got replaced with 4th row and vice versa.
Now when i try to delete the 4th row, it is delete the 2nd row data, which was there at the place of 4th row before sorting. In this regard i am trying to print the row number before deleting. It is displaying as 4th, but deleting 2nd row.
Hope i am clear. Please suggest me in solving this strange behavior of JTable sorting problem.
Regards,
Ravi
# 2
for sorting the table data i am using the below java code as is, from 'How to Use JTable' site.
http://java.sun.com/docs/books/tutorial/uiswing/examples/components/TableSorterDemoProject/src/components/TableSorter.java
Please suggest whether to make any changes in this code.
# 4
MyTableModel tablemodel = new MyTableModel(colnames,values);
TableSorter sorter = new TableSorter(tablemodel);
JTable table = new JTable(sorter)
tablemodel.removeRow(row);
// last line is the code where i am deleting the row, it's deleting the wrong row.
do i need to remove the last line code and make respective changes in TableSorter.java class.
ore
here itself do i need to do some changes. ?
>There is a method that will convert the view row to the model row
private Row[] getViewToModel()
my question is how TableSorter.java class comes to know that i am deleting the perticular row.